qiniu 6.8.1 → 6.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
-
5
- Qiniu.establish_connection! :access_key => 'Access_Key',
6
- :secret_key => 'Secret_Key'
7
-
8
- #你要测试的空间, 并且这个key在你空间中存在
9
- bucket = 'Bucket_Name'
10
- key = 'ruby-logo.png'
11
-
12
- #复制到的目标空间名和重命名的key
13
- dst_bucket = 'dst_bucket'
14
- dst_key = 'dst_key'
15
-
16
- #复制文件
17
- code, result, response_headers = Qiniu::Storage.copy(
18
- bucket, # 源存储空间
19
- key, # 源资源名
20
- dst_bucket, # 目标存储空间
21
- dst_key # 目标资源名
22
- )
23
- puts code
24
- puts result
25
- puts response_headers
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
-
5
- Qiniu.establish_connection! :access_key => 'Access_Key',
6
- :secret_key => 'Secret_Key'
7
-
8
- #你要测试的空间, 并且这个key在你空间中存在
9
- bucket = 'Bucket_Name'
10
- key = 'ruby-logo.png'
11
-
12
- #删除资源
13
- code, result, response_headers = Qiniu::Storage.delete(
14
- bucket, # 存储空间
15
- key # 资源名
16
- )
17
-
18
- puts code
19
- puts result
20
- puts response_headers
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
-
5
- Qiniu.establish_connection! :access_key => 'AK',
6
- :secret_key => 'SK'
7
-
8
- #构建私有空间的链接
9
- primitive_url = 'http://domain/key'
10
- download_url = Qiniu::Auth.authorize_download_url(primitive_url)
11
- puts download_url
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
-
5
- Qiniu.establish_connection! :access_key => 'xxx',
6
- :secret_key => 'xxx'
7
-
8
- #需要fetch操作保存到的空间名
9
- bucket = 'xxx'
10
- #fetch过来的url,需要外网可以访问到
11
- target_url = 'url'
12
- #保存到空间的fetch操作的文件名
13
- key = 'xxx'
14
-
15
- #调用fetch方法
16
- code, result, response_headers = Qiniu::Storage.fetch(
17
- bucket,
18
- target_url,
19
- key
20
- )
21
-
22
- #打印返回的状态码以及信息
23
- puts code
24
- puts result
25
- puts response_headers
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
- require 'qiniu/utils'
5
-
6
- # 构建鉴权对象
7
- Qiniu.establish_connection! :access_key => 'AK',
8
- :secret_key => 'SK'
9
-
10
- #要转码的文件所在的空间和文件名。
11
- bucket = 'Bucket_Name'
12
- key = '1.mp4'
13
-
14
- #转码所使用的队列名称。
15
- pipeline = 'abc'
16
-
17
- #要进行转码的转码操作。
18
- fops = "avthumb/mp4/s/640x360/vb/1.25m"
19
-
20
-
21
- #可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当间。
22
- saveas_key = Qiniu::Utils.urlsafe_base64_encode(目标Bucket_Name:自定义文件key)
23
- fops = fops+'|saveas/'+saveas_key
24
-
25
- pfops = Qiniu::Fop::Persistance::PfopPolicy.new(
26
- bucket, # 存储空间
27
- key, # 最终资源名,可省略,即缺省为“创建”语义
28
- fops,
29
- 'www.baidu.com'
30
- )
31
- pfops.pipeline=pipeline
32
-
33
- code, result, response_headers = Qiniu::Fop::Persistance.pfop(pfops)
34
- puts code
35
- puts result
36
- puts response_headers
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
-
5
- Qiniu.establish_connection! :access_key => 'xxxx',
6
- :secret_key => 'xxxx'
7
-
8
- #你要测试的list的空间名
9
- bucket = 'xxxx'
10
-
11
- #调用list接口,参数可以参考 http://developer.qiniu.com/code/v6/api/kodo-api/rs/list.html#list-specification
12
- code, result, response_headers, s, d = Qiniu::Storage.list(Qiniu::Storage::ListPolicy.new(
13
- bucket, # bucket
14
- 100, # limit
15
- 'photo/', # prefix
16
- '' # delimiter
17
- ))
18
- #打印出返回的状态码和信息
19
- puts code
20
- puts result
21
- puts response_headers
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
-
5
- Qiniu.establish_connection! :access_key => 'Access_Key',
6
- :secret_key => 'Secret_Key'
7
-
8
- #你要测试的空间, 并且这个key在你空间中存在
9
- bucket = 'Bucket_Name';
10
- key = 'ruby-logo.png';
11
-
12
- #移动到的目标空间名和重命名的key
13
- dst_bucket = 'dst_bucket'
14
- dst_key = 'dst_key'
15
-
16
-
17
- #移动文件
18
- code, result, response_headers = Qiniu::Storage.move(
19
- bucket, # 源存储空间
20
- key, # 源资源名
21
- dst_bucket, # 目标存储空间
22
- dst_key # 目标资源名
23
- )
24
- puts code
25
- puts result
26
- puts response_headers
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
- require 'qiniu/utils'
5
-
6
- # 构建鉴权对象
7
- Qiniu.establish_connection! :access_key => 'AK',
8
- :secret_key => 'SK'
9
-
10
- #要转码的文件所在的空间和文件名。
11
- bucket = 'Bucket_Name'
12
- key = '1.mp4'
13
-
14
- #转码所使用的队列名称。
15
- pipeline = 'abc'
16
-
17
- #要进行视频截图操作。
18
- fops = "vframe/jpg/offset/1/w/480/h/360/rotate/90"
19
-
20
-
21
- #可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当间。
22
- saveas_key = Qiniu::Utils.urlsafe_base64_encode(目标Bucket_Name:自定义文件key)
23
- fops = fops+'|saveas/'+saveas_key
24
-
25
- pfops = Qiniu::Fop::Persistance::PfopPolicy.new(
26
- bucket, # 存储空间
27
- key, # 最终资源名,可省略,即缺省为“创建”语义
28
- fops,
29
- 'www.baidu.com'
30
- )
31
- pfops.pipeline=pipeline
32
-
33
- code, result, response_headers = Qiniu::Fop::Persistance.pfop(pfops)
34
- puts code
35
- puts result
36
- puts response_headers
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
- require 'qiniu/utils'
5
-
6
- # 构建鉴权对象
7
- Qiniu.establish_connection! :access_key => 'AK',
8
- :secret_key => 'SK'
9
-
10
- #要转码的文件所在的空间和文件名。
11
- bucket = 'Bucket_Name'
12
- key = '1.mp4'
13
-
14
- #转码所使用的队列名称。
15
- pipeline = 'abc'
16
-
17
- #需要添加水印的图片UrlSafeBase64,可以参考http://developer.qiniu.com/code/v6/api/dora-api/av/video-watermark.html
18
- base64URL = Qiniu::Utils.urlsafe_base64_encode('http://developer.qiniu.com/resource/logo-2.jpg')
19
-
20
- #水印参数
21
- fops = "avthumb/mp4/wmImage"+base64URL
22
-
23
- #可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当间。
24
- saveas_key = Qiniu::Utils.urlsafe_base64_encode(目标Bucket_Name:自定义文件key)
25
- fops = fops+'|saveas/'+saveas_key
26
-
27
- pfops = Qiniu::Fop::Persistance::PfopPolicy.new(
28
- bucket, # 存储空间
29
- key, # 最终资源名,可省略,即缺省为“创建”语义
30
- fops,
31
- 'www.baidu.com'
32
- )
33
- pfops.pipeline=pipeline
34
-
35
- code, result, response_headers = Qiniu::Fop::Persistance.pfop(pfops)
36
- puts code
37
- puts result
38
- puts response_headers
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
-
5
- Qiniu.establish_connection! :access_key => 'Access_Key',
6
- :secret_key => 'Secret_Key'
7
-
8
- #你要测试的空间, 并且这个key在你空间中存在
9
- bucket = 'Bucket_Name';
10
- key = 'ruby-logo.png';
11
-
12
- #获取文件信息
13
- code, result, response_headers = Qiniu::Storage.stat(
14
- bucket, # 存储空间
15
- key # 资源名
16
- )
17
- puts code
18
- puts result
19
- puts response_headers
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
-
5
- # 构建鉴权对象
6
- Qiniu.establish_connection! :access_key => 'Access_Key',
7
- :secret_key => 'Secret_Key'
8
-
9
- #要上传的空间
10
- bucket = 'Bucket_Name'
11
-
12
- #上传到七牛后保存的文件名
13
- key = 'my-ruby-logo.png'
14
-
15
-
16
- #构建上传策略
17
- put_policy = Qiniu::Auth::PutPolicy.new(
18
- bucket, # 存储空间
19
- key, # 最终资源名,可省略,即缺省为“创建”语义,设置为nil为普通上传
20
- 3600 #token过期时间,默认为3600s
21
- )
22
-
23
- #生成上传 Token
24
- uptoken = Qiniu::Auth.generate_uptoken(put_policy)
25
-
26
- #要上传文件的本地路径
27
- filePath = './ruby-logo.png'
28
-
29
- #调用upload_with_token_2方法上传
30
- code, result, response_headers = Qiniu::Storage.upload_with_token_2(
31
- uptoken,
32
- filePath,
33
- key
34
- )
35
-
36
- #打印上传返回的信息
37
- puts code
38
- puts result
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
-
5
- # 构建鉴权对象
6
- Qiniu.establish_connection! :access_key => 'Access_Key',
7
- :secret_key => 'Secret_Key'
8
-
9
- bucket = 'Bucket_Name'
10
-
11
- key = 'my-ruby-logo.png'
12
-
13
- put_policy = Qiniu::Auth::PutPolicy.new(
14
- bucket, # 存储空间
15
- key, # 最终资源名,可省略,即缺省为“创建”语义,设置为nil为普通上传
16
- 3600 #token过期时间,默认为3600s
17
- )
18
-
19
- #构建回调策略,这里上传文件到七牛后, 七牛将文件名和文件大小回调给业务服务器.
20
- callback_url = 'http://your.domain.com/callback'
21
- callback_body = 'filename=$(fname)&filesize=$(fsize)'
22
-
23
- put_policy.callback_url= callback_url
24
- put_policy.callback_body= callback_body
25
-
26
- #生成上传 Token
27
- uptoken = Qiniu::Auth.generate_uptoken(put_policy)
28
-
29
- #要上传文件的本地路径
30
- filePath = './ruby-logo.png'
31
-
32
- #调用upload_with_token_2方法上传
33
- code, result, response_headers = Qiniu::Storage.upload_with_token_2(
34
- uptoken,
35
- filePath,
36
- key
37
- )
38
-
39
- #打印上传返回的信息
40
- puts code
41
- puts result
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'qiniu'
4
-
5
- # 构建鉴权对象
6
- Qiniu.establish_connection! :access_key => 'Access_Key',
7
- :secret_key => 'Secret_Key'
8
-
9
- bucket = 'Bucket_Name'
10
-
11
- key = 'my-ruby-logo.png'
12
-
13
- put_policy = Qiniu::Auth::PutPolicy.new(
14
- bucket, # 存储空间
15
- key, # 最终资源名,可省略,即缺省为“创建”语义,设置为nil为普通上传
16
- 3600 #token过期时间,默认为3600s
17
- )
18
-
19
- #转码是使用的队列名称。
20
- pipeline = 'abc' #设定自己账号下的pipleline
21
-
22
- #要进行转码的转码操作。
23
- fops = "avthumb/mp4/s/640x360/vb/1.25m"
24
-
25
- #可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当间。
26
- saveas_key = Qiniu::Utils.urlsafe_base64_encode(目标Bucket_Name:自定义文件key)
27
- fops = fops+'|saveas/'+saveas_key
28
-
29
- put_policy.persistent_ops= fops
30
- put_policy.persistent_pipeline= pipeline
31
-
32
- #生成上传 Token
33
- uptoken = Qiniu::Auth.generate_uptoken(put_policy)
34
-
35
- #要上传文件的本地路径
36
- filePath = './ruby-logo.png'
37
-
38
- #调用upload_with_token_2方法上传
39
- code, result, response_headers = Qiniu::Storage.upload_with_token_2(
40
- uptoken,
41
- filePath,
42
- key
43
- )
44
-
45
- #打印上传返回的信息
46
- puts code
47
- puts result
@@ -1,29 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require File.expand_path('../lib/qiniu/version', __FILE__)
4
-
5
- Gem::Specification.new do |gem|
6
- gem.authors = ['why404','BluntBlade']
7
- gem.email = ['sdk@qiniu.com']
8
- gem.description = %q{Qiniu Resource (Cloud) Storage SDK for Ruby. See: http://developer.qiniu.com/docs/v6/sdk/ruby-sdk.html}
9
- gem.summary = %q{Qiniu Resource (Cloud) Storage SDK for Ruby}
10
- gem.homepage = 'https://github.com/qiniu/ruby-sdk'
11
-
12
- gem.files = `git ls-files`.split($\)
13
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
- gem.test_files = gem.files.grep(%r{^(test|spec|features|examples)/})
15
- gem.name = 'qiniu'
16
- gem.require_paths = ['lib']
17
- gem.version = Qiniu::Version.to_s
18
- gem.license = 'MIT'
19
-
20
- # specify any dependencies here; for example:
21
- gem.add_development_dependency 'rake', '~> 0.9'
22
- gem.add_development_dependency 'rspec', '~> 2.11'
23
- gem.add_development_dependency 'fakeweb', '~> 1.3'
24
- gem.add_runtime_dependency 'json', '~> 1.8'
25
- gem.add_runtime_dependency 'rest-client', '~> 2.0', '>= 2.0.0'
26
- gem.add_runtime_dependency 'mime-types', '~> 2.4', '>= 2.4.0'
27
- gem.add_runtime_dependency 'ruby-hmac', '~> 0.4'
28
- gem.add_runtime_dependency 'jruby-openssl', '~> 0.7' if RUBY_PLATFORM == 'java'
29
- end
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rails3/qiniu.gemspec
4
- gemspec :name => 'qiniu'
@@ -1,29 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require File.expand_path('../../lib/qiniu/version', __FILE__)
4
-
5
- Gem::Specification.new do |gem|
6
- gem.authors = ["why404","BluntBlade"]
7
- gem.email = ["sdk@qiniu.com"]
8
- gem.description = %q{Qiniu Resource (Cloud) Storage SDK for Ruby. See: http://developer.qiniu.com/docs/v6/sdk/ruby-sdk.html}
9
- gem.summary = %q{Qiniu Resource (Cloud) Storage SDK for Ruby}
10
- gem.homepage = "https://github.com/qiniu/ruby-sdk"
11
-
12
- gem.files = `git ls-files`.split($\)
13
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
- gem.name = "qiniu"
16
- gem.require_paths = ["lib"]
17
- gem.version = Qiniu::Version.to_s
18
- gem.license = "MIT"
19
-
20
- # specify any dependencies here; for example:
21
- gem.add_development_dependency "rake", ">= 0.9"
22
- gem.add_development_dependency "rspec", ">= 2.11"
23
- gem.add_development_dependency "fakeweb", "~> 1.3"
24
- gem.add_runtime_dependency "json", "~> 1.8"
25
- gem.add_runtime_dependency "rest-client", "~> 1.8.0"
26
- gem.add_runtime_dependency "mime-types", "~> 1.19"
27
- gem.add_runtime_dependency "ruby-hmac", "~> 0.4"
28
- gem.add_runtime_dependency "jruby-openssl", "~> 0.7" if RUBY_PLATFORM == "java"
29
- end