qiniu_jxb_fix 6.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/.gitignore +18 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +12 -0
  4. data/CHANGELOG.md +146 -0
  5. data/Gemfile +8 -0
  6. data/Gemfile.lock +44 -0
  7. data/LICENSE +22 -0
  8. data/README.md +47 -0
  9. data/Rakefile +21 -0
  10. data/docs/README.md +790 -0
  11. data/lib/qiniu/abstract.rb +22 -0
  12. data/lib/qiniu/adt.rb +46 -0
  13. data/lib/qiniu/auth.rb +255 -0
  14. data/lib/qiniu/config.rb +60 -0
  15. data/lib/qiniu/exceptions.rb +120 -0
  16. data/lib/qiniu/fop.rb +4 -0
  17. data/lib/qiniu/http.rb +137 -0
  18. data/lib/qiniu/image.rb +38 -0
  19. data/lib/qiniu/log.rb +15 -0
  20. data/lib/qiniu/management.rb +166 -0
  21. data/lib/qiniu/misc.rb +35 -0
  22. data/lib/qiniu/pfop.rb +124 -0
  23. data/lib/qiniu/resumable_upload.rb +319 -0
  24. data/lib/qiniu/storage.rb +5 -0
  25. data/lib/qiniu/tokens/access_token.rb +23 -0
  26. data/lib/qiniu/tokens/download_token.rb +36 -0
  27. data/lib/qiniu/tokens/qbox_token.rb +38 -0
  28. data/lib/qiniu/tokens/upload_token.rb +57 -0
  29. data/lib/qiniu/upload.rb +134 -0
  30. data/lib/qiniu/utils.rb +109 -0
  31. data/lib/qiniu/version.rb +17 -0
  32. data/lib/qiniu-rs.rb +2 -0
  33. data/lib/qiniu.rb +209 -0
  34. data/qiniu.gemspec +29 -0
  35. data/rails3/Gemfile +4 -0
  36. data/rails3/qiniu.gemspec +29 -0
  37. data/spec/qiniu/abstract_spec.rb +30 -0
  38. data/spec/qiniu/auth_spec.rb +74 -0
  39. data/spec/qiniu/image_logo_for_test.png +0 -0
  40. data/spec/qiniu/image_spec.rb +80 -0
  41. data/spec/qiniu/management_spec.rb +163 -0
  42. data/spec/qiniu/misc_spec.rb +53 -0
  43. data/spec/qiniu/pfop_spec.rb +80 -0
  44. data/spec/qiniu/qiniu_spec.rb +321 -0
  45. data/spec/qiniu/tokens/qbox_token_spec.rb +29 -0
  46. data/spec/qiniu/upload_spec.rb +301 -0
  47. data/spec/qiniu/utils_spec.rb +49 -0
  48. data/spec/qiniu/version_spec.rb +10 -0
  49. data/spec/spec_helper.rb +19 -0
  50. metadata +222 -0
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ .DS_Store
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour -f documentation
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.1
6
+ - jruby-19mode
7
+ before_script:
8
+ - export QINIU_ACCESS_KEY=QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm
9
+ - export QINIU_SECRET_KEY=Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz
10
+ gemfile:
11
+ - Gemfile
12
+ - rails3/Gemfile
data/CHANGELOG.md ADDED
@@ -0,0 +1,146 @@
1
+ ## CHANGE LOG
2
+
3
+ ### v6.4.2
4
+
5
+ - gem 兼容性调整 。 [https://github.com/qiniu/ruby-sdk/pull/122](https://github.com/qiniu/ruby-sdk/pull/122)
6
+
7
+ - 上传策略参数调整 。 [https://github.com/qiniu/ruby-sdk/pull/120](https://github.com/qiniu/ruby-sdk/pull/120)
8
+
9
+ ### v6.4.1
10
+
11
+ - 将 mime-types 的依赖版本升级到 2.4.3 。 [https://github.com/qiniu/ruby-sdk/pull/113](https://github.com/qiniu/ruby-sdk/pull/113)
12
+
13
+ ### v6.4.0
14
+
15
+ - 为 put_with_put_policy() 添加 opts 参数,允许使用 :content_type 键指定上传文件的 mime type。 [https://github.com/qiniu/ruby-sdk/pull/111](https://github.com/qiniu/ruby-sdk/pull/111)
16
+
17
+ ### v6.3.2
18
+
19
+ - 调整上传host。 [https://github.com/qiniu/ruby-sdk/pull/103](https://github.com/qiniu/ruby-sdk/pull/103)
20
+
21
+ ### v6.3.1
22
+
23
+ - 为过期方法添加说明。 [https://github.com/qiniu/ruby-sdk/pull/98](https://github.com/qiniu/ruby-sdk/pull/98)
24
+ - 修改上传域名。 [https://github.com/qiniu/ruby-sdk/pull/99](https://github.com/qiniu/ruby-sdk/pull/99)
25
+ - 增加pfop参数。 [https://github.com/qiniu/ruby-sdk/pull/100](https://github.com/qiniu/ruby-sdk/pull/100)
26
+
27
+ ### v6.3.0
28
+
29
+ - 添加 authorize_download_url_2 方法,对包含中文或其它 utf-8 字符的 Key 做下载授权。 [https://github.com/qiniu/ruby-sdk/pull/95](https://github.com/qiniu/ruby-sdk/pull/95)
30
+
31
+ ### v6.2.4
32
+
33
+ - 调整User Agent。 [https://github.com/qiniu/ruby-sdk/pull/94](https://github.com/qiniu/ruby-sdk/pull/94)
34
+
35
+ ### v6.2.3
36
+
37
+ - 为上传策略添加`persistentPipeline`参数,用于指明使用哪个命名转码队列。 [https://github.com/qiniu/ruby-sdk/pull/93](https://github.com/qiniu/ruby-sdk/pull/93)
38
+
39
+ ### v6.2.2
40
+
41
+ - 为/pfop接口添加`pipeline`参数,用于指明使用哪个命名转码队列。 [https://github.com/qiniu/ruby-sdk/pull/92](https://github.com/qiniu/ruby-sdk/pull/92)
42
+ - 为authorize_download_url()添加`:fop`参数,用于生成含数据处理指令的授权下载URL。
43
+
44
+ ### v6.2.1
45
+
46
+ - 去除已废弃的publish/unpublish接口。 [https://github.com/qiniu/ruby-sdk/pull/90](https://github.com/qiniu/ruby-sdk/pull/90) (#8143)
47
+
48
+ ### v6.2.0
49
+
50
+ - 重写与授权相关的函数并归入Qiniu::Auth空间,原授权凭证生成类维持不变。
51
+
52
+ - 添加Qiniu::Storage::PutPolicy类和Qiniu::Storage#upload_with_put_policy方法,并推荐使用两者组合实现单文件上传。
53
+
54
+ ### v6.1.0
55
+
56
+ - Qiniu::Storage所有上传接口返回第三个值raw_headers,类型为Hash,包含已解析的HTTP响应报文中的所有Header信息。
57
+
58
+ 该返回值主要用于调试。当遇到难以理解或解释的错误时,请将其中的X-Log和X-Reqid两项信息[通过邮件反馈](mailto:support@qiniu.com?subject=Ruby-SDK-Bug-Report)给我们。
59
+
60
+ - 更新Qiniu::Storage所有上传接口的测试用例,打印HTTP响应Header信息。
61
+
62
+ - 删除过时的Qiniu::Storage#put_file方法和相关测试用例。
63
+
64
+ 该方法调用的API已过时并逐步废弃,建议用户尽快迁移到Qiniu::Storage#upload_with_token_2方法上。
65
+
66
+ ### v6.0.1
67
+
68
+ - 重新划分命名空间,存储相关归入Qiniu::Storage,数据处理相关归入Qiniu::Fop,杂项相关归入Qiniu::Misc。
69
+
70
+ ### v3.4.6
71
+
72
+ - `Qiniu::RS.generate_download_token()` 方法的 `:pattern` 调整为必选项。
73
+
74
+ ### v3.4.5
75
+
76
+ - `Qiniu::RS.generate_upload_token()` 方法新增 `:callback_body` 和 `return_url` 选项。
77
+ - 选项含义参考: <http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-callback-body>
78
+
79
+ ### v3.4.2
80
+
81
+ - `Qiniu::RS.generate_upload_token()` 方法新增 `:return_body` 选项。
82
+
83
+ 该选项(`:return_body`)可设置文件上传成功后,执行七牛云存储规定的回调API,并以 JSON 响应格式返回其执行结果。参考 [uploadToken 之 returnBody 说明](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-return-body)。
84
+
85
+ ### v3.4.1
86
+
87
+ 增加为上传文件进行预转的选项,参见 [uploadToken 之 asyncOps 说明](http://docs.qiniu.com/api/v6/put.html#uploadToken-asyncOps)
88
+
89
+ - `Qiniu::RS.generate_upload_token()` 方法新增 `:async_options` 选项用于进行预转操作。
90
+
91
+ ### v3.4.0
92
+
93
+ 增加文件复制/移动方法,包括批量复制/移动文件
94
+
95
+ - `Qiniu::RS.copy(source_bucket, source_key, target_bucket, target_key)`
96
+ - `Qiniu::RS.move(source_bucket, source_key, target_bucket, target_key)`
97
+ - `Qiniu::RS.batch_copy [source_bucket, source_key, target_bucket, target_key], ...`
98
+ - `Qiniu::RS.batch_move [source_bucket, source_key, target_bucket, target_key], ...`
99
+
100
+ ### v3.3.1
101
+
102
+ 确保单元测试里边用到的测试 Bucket 全局唯一
103
+
104
+ 使得10多种不通的 Ruby 宿主环境能隔离互不影响地执行单元/集成测试
105
+
106
+ Ruby 宿主环境如下
107
+
108
+ 1.8.7, 1.9.2, 1.9.3, jruby-18mode, jruby-19mode, rbx-18mode, rbx-19mode, ruby-head, jruby-head, ree
109
+
110
+ 详见 <https://travis-ci.org/qiniu/ruby-sdk>
111
+
112
+ ### v3.3.0
113
+
114
+ 私有资源下载新版实现,添加 Qiniu::RS.generate_download_token() 方法。参考 [downloadToken](http://developer.qiniu.com/docs/v6/api/reference/security/download-token.html)
115
+
116
+ 详见 [Ruby SDK 使用文档之私有资源下载](http://developer.qiniu.com/docs/v6/api/overview/dn/security.html)
117
+
118
+ ### v3.2.2
119
+
120
+ fixed E701 error
121
+
122
+ 断点续上传根据 mkblk 返回的 host 字段进行 bput 和 mkfile ,规避由于DNS智能解析造成的分布式并行块上传会出现上下文不连贯导致的 E701 问题。
123
+
124
+ ### v3.2.1
125
+
126
+ allow images uploaded auto-orient.
127
+
128
+ 允许图片上传成功后自动旋转。
129
+
130
+ 参考:
131
+
132
+ 1. [[API] multipart/form-data 上传文件之 action 字段详解](http://docs.qiniutek.com/v3/api/io/#upload-action)
133
+ 2. [[SDK] Qiniu::RS.upload_file() 方法中的参数增加了 :rotate 选项](http://docs.qiniutek.com/v3/sdk/ruby/#upload-server-side)
134
+
135
+ ### v3.2.0
136
+
137
+ 2012-11-06
138
+
139
+ allow files uploaded auto callback some APIs (like imageInfo, exif, etc…), and add those APIs callback results as part of the custom data for POST biz-server.
140
+
141
+ 允许上传文件(图片)成功后执行回调指定的 API (比如 imageInfo, exif 接口等),并将指定API的回调结果一并 POST 发送给客户方的业务服务器。
142
+
143
+ 参考:
144
+
145
+ 1. [[API] 生成上传授权凭证 uploadToken 之 escape 参数详解](http://docs.qiniutek.com/v3/api/io/#escape-expression)
146
+ 2. [[SDK] Qiniu::RS.generate_upload_token() 方法中的参数增加了 :escape 选项](http://docs.qiniutek.com/v3/sdk/ruby/#generate-upload-token)
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in qiniu.gemspec
4
+ gemspec :name => 'qiniu'
5
+
6
+ # platforms :jruby do
7
+ # gem "jruby-openssl"
8
+ # end
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ qiniu (6.4.2)
5
+ json (~> 1.8)
6
+ mime-types (~> 1.19)
7
+ rest-client (~> 1.7.3)
8
+ ruby-hmac (~> 0.4)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ diff-lcs (1.2.5)
14
+ fakeweb (1.3.0)
15
+ json (1.8.2)
16
+ mime-types (1.25.1)
17
+ netrc (0.10.3)
18
+ rake (10.4.2)
19
+ rest-client (1.7.3)
20
+ mime-types (>= 1.16, < 3.0)
21
+ netrc (~> 0.7)
22
+ rspec (3.2.0)
23
+ rspec-core (~> 3.2.0)
24
+ rspec-expectations (~> 3.2.0)
25
+ rspec-mocks (~> 3.2.0)
26
+ rspec-core (3.2.2)
27
+ rspec-support (~> 3.2.0)
28
+ rspec-expectations (3.2.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.2.0)
31
+ rspec-mocks (3.2.1)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.2.0)
34
+ rspec-support (3.2.2)
35
+ ruby-hmac (0.4.0)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ fakeweb (~> 1.3)
42
+ qiniu!
43
+ rake (>= 0.9)
44
+ rspec (>= 2.11)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012-2013 qiniutek.com
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Qiniu Resource (Cloud) Storage SDK for Ruby
2
+
3
+ ## 关于
4
+
5
+ 此 Ruby SDK 适用于 Ruby 1.9.x, 2.0.x, 2.1.x, jruby版本,基于 [七牛云存储官方API](http://developer.qiniu.com/docs/v6/index.html) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
6
+
7
+ ## 状态
8
+
9
+ [![Build Status](https://api.travis-ci.org/qiniu/ruby-sdk.png?branch=master)](https://travis-ci.org/qiniu/ruby-sdk)
10
+ [![Gem Version](https://badge.fury.io/rb/qiniu.png)](http://badge.fury.io/rb/qiniu)
11
+ [![Dependency Status](https://gemnasium.com/qiniu/ruby-sdk.png)](https://gemnasium.com/qiniu/ruby-sdk)
12
+ [![Code Climate](https://codeclimate.com/github/qiniu/ruby-sdk.png)](https://codeclimate.com/github/qiniu/ruby-sdk)
13
+
14
+ ## 安装
15
+
16
+ 在您 Ruby 应用程序的 `Gemfile` 文件中,添加如下一行代码:
17
+
18
+ gem 'qiniu', '~> 6.4.1'
19
+
20
+ 然后,在应用程序所在的目录下,可以运行 `bundle` 安装依赖包:
21
+
22
+ $ bundle
23
+
24
+ 或者,可以使用 Ruby 的包管理器 `gem` 进行安装:
25
+
26
+ $ gem install qiniu
27
+
28
+ ## 使用
29
+
30
+ 参考文档:[七牛云存储 Ruby SDK 使用指南](http://developer.qiniu.com/docs/v6/sdk/ruby-sdk.html)
31
+
32
+ ## 贡献代码
33
+
34
+ 1. Fork
35
+ 2. 创建您的特性分支 (`git checkout -b my-new-feature`)
36
+ 3. 提交您的改动 (`git commit -am 'Added some feature'`)
37
+ 4. 将您的修改记录提交到远程 `git` 仓库 (`git push origin my-new-feature`)
38
+ 5. 然后到 github 网站的该 `git` 远程仓库的 `my-new-feature` 分支下发起 Pull Request
39
+
40
+ ## 许可证
41
+
42
+ Copyright (c) 2012-2014 qiniu.com
43
+
44
+ 基于 MIT 协议发布:
45
+
46
+ * [www.opensource.org/licenses/MIT](http://www.opensource.org/licenses/MIT)
47
+
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ require "bundler/gem_tasks"
6
+
7
+ begin
8
+ Bundler.setup(:default, :development)
9
+ rescue Bundler::BundlerError => e
10
+ $stderr.puts e.message
11
+ $stderr.puts "Run `bundle install` to install missing gems"
12
+ exit e.status_code
13
+ end
14
+
15
+ require 'rspec/core'
16
+ require 'rspec/core/rake_task'
17
+ RSpec::Core::RakeTask.new(:spec) do |spec|
18
+ spec.pattern = FileList['spec/**/*_spec.rb']
19
+ end
20
+
21
+ task :default => :spec