paperclip-qiniu 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +1,40 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paperclip-qiniu (0.0.2)
4
+ paperclip-qiniu (0.0.3)
5
5
  paperclip
6
- qiniu-rs
6
+ qiniu-rs (~> 3.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (3.2.6)
12
- activesupport (= 3.2.6)
11
+ activemodel (3.2.8)
12
+ activesupport (= 3.2.8)
13
13
  builder (~> 3.0.0)
14
- activerecord (3.2.6)
15
- activemodel (= 3.2.6)
16
- activesupport (= 3.2.6)
14
+ activerecord (3.2.8)
15
+ activemodel (= 3.2.8)
16
+ activesupport (= 3.2.8)
17
17
  arel (~> 3.0.2)
18
18
  tzinfo (~> 0.3.29)
19
- activesupport (3.2.6)
19
+ activesupport (3.2.8)
20
20
  i18n (~> 0.6)
21
21
  multi_json (~> 1.0)
22
22
  arel (3.0.2)
23
23
  builder (3.0.0)
24
- cocaine (0.2.1)
24
+ cocaine (0.3.0)
25
25
  diff-lcs (1.1.3)
26
- i18n (0.6.0)
27
- json (1.7.3)
26
+ i18n (0.6.1)
27
+ json (1.7.5)
28
28
  mime-types (1.19)
29
29
  multi_json (1.3.6)
30
- paperclip (3.1.3)
30
+ paperclip (3.1.4)
31
31
  activemodel (>= 3.0.0)
32
32
  activerecord (>= 3.0.0)
33
33
  activesupport (>= 3.0.0)
34
34
  cocaine (>= 0.0.2)
35
35
  mime-types
36
- qiniu-rs (2.1.2)
37
- json (~> 1.7.3)
36
+ qiniu-rs (3.0.5)
37
+ json (~> 1.7.5)
38
38
  mime-types (~> 1.19)
39
39
  rest-client (~> 1.6.7)
40
40
  ruby-hmac (~> 0.4.0)
@@ -44,10 +44,10 @@ GEM
44
44
  rspec-core (~> 2.11.0)
45
45
  rspec-expectations (~> 2.11.0)
46
46
  rspec-mocks (~> 2.11.0)
47
- rspec-core (2.11.0)
48
- rspec-expectations (2.11.1)
47
+ rspec-core (2.11.1)
48
+ rspec-expectations (2.11.3)
49
49
  diff-lcs (~> 1.1.3)
50
- rspec-mocks (2.11.1)
50
+ rspec-mocks (2.11.2)
51
51
  ruby-hmac (0.4.0)
52
52
  tzinfo (0.3.33)
53
53
 
data/README.md CHANGED
@@ -58,6 +58,10 @@ end
58
58
 
59
59
  ## CHANGELOG
60
60
 
61
+ ### 0.0.3 (2012-09-06)
62
+
63
+ * support qiniu api v3.
64
+
61
65
  ### 0.0.2 (2012-07-17)
62
66
 
63
67
  * support public host.
@@ -0,0 +1,6 @@
1
+ module Paperclip
2
+ module Qiniu
3
+ class Error < StandardError; end
4
+ class UploadFailed < Error; end
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module Qiniu
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -1,3 +1,5 @@
1
+ require 'paperclip-qiniu/exceptions'
2
+
1
3
  module Paperclip
2
4
  module Storage
3
5
  module Qiniu
@@ -74,14 +76,16 @@ module Paperclip
74
76
  end
75
77
 
76
78
  def upload(file, path)
77
- remote_upload_url = ::Qiniu::RS.put_auth
78
- opts = {:url => remote_upload_url,
79
+ upload_token = ::Qiniu::RS.generate_upload_token :scope => bucket
80
+ opts = {:uptoken => upload_token,
79
81
  :file => file.path,
80
82
  :key => path,
81
83
  :bucket => bucket,
82
84
  :mime_type => file.content_type,
83
85
  :enable_crc32_check => true}
84
- ::Qiniu::RS.upload opts
86
+ unless ::Qiniu::RS.upload_file(opts)
87
+ raise Paperclip::Qiniu::UploadFailed
88
+ end
85
89
  end
86
90
 
87
91
  def bucket
@@ -15,6 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Paperclip::Qiniu::VERSION
17
17
  gem.add_dependency 'paperclip'
18
- gem.add_dependency 'qiniu-rs'
18
+ gem.add_dependency 'qiniu-rs', '~> 3.0'
19
19
  gem.add_development_dependency 'rspec'
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-qiniu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-17 00:00:00.000000000 Z
12
+ date: 2012-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: paperclip
@@ -32,17 +32,17 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '0'
37
+ version: '3.0'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '0'
45
+ version: '3.0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rspec
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -74,6 +74,7 @@ files:
74
74
  - README.md
75
75
  - Rakefile
76
76
  - lib/paperclip-qiniu.rb
77
+ - lib/paperclip-qiniu/exceptions.rb
77
78
  - lib/paperclip-qiniu/version.rb
78
79
  - lib/paperclip/storage/qiniu.rb
79
80
  - paperclip-qiniu.gemspec