carrierwave-aliyun 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7e1a032a15f971ac7d1557dbae299ad9076d140
4
- data.tar.gz: 85fe40058d6305cadb67a3a1c60485ad70abf25f
3
+ metadata.gz: a8cb423fe32332c16b3621cb4b986b4c33288e73
4
+ data.tar.gz: 6693a677b786138041c6d4cd44032afd9ae6269f
5
5
  SHA512:
6
- metadata.gz: 3723c0a1664b2f323f07100a85fba1de96636e6542c4b3ddeb57996c56e16e55633a36676d0c13455500139236c33283c9313f8facea5d195443234da6bb61a4
7
- data.tar.gz: 2e936b1cf3a2eded52064bb2382acb6800390ca09fbe6f6845c69396738215aa953e783ed7b2e8684c1d634399ad30a6191bd5d8fb2516a5c6fd325258e215ac
6
+ metadata.gz: 67d2dc2aad2650f46f0378594694016ce88a7d217c8ba48a1a087f7ae510884e65356666d1d3a6ee8101478a06d5e543ac7f9532df0c47619966845b94023b9f
7
+ data.tar.gz: f5a212545459c9604ea38eb6ba7d2839c7f4b830838b25590de9df6c451d34c3a932f188397456006119a3e2f90445014bcd2097d507f8daf69ce42779ea1cb1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.6
2
+
3
+ * 修正上传中文文件名无法成功的问题;
4
+
1
5
  ## 0.3.5
2
6
 
3
7
  * CarrierWave::Storage::Aliyun::File 继承 CarrierWave::SanitizedFile 以实现一些方法;
@@ -1,7 +1,7 @@
1
1
  module CarrierWave
2
2
  module Aliyun
3
3
  class Version
4
- MAJOR, MINOR, PATCH = 0, 3, 5
4
+ MAJOR, MINOR, PATCH = 0, 3, 6
5
5
 
6
6
  ##
7
7
  # Returns the major version ( big release based off of multiple minor releases )
@@ -49,7 +49,7 @@ module CarrierWave
49
49
  content_type = options[:content_type] || "image/jpg"
50
50
  date = gmtdate
51
51
  url = path_to_url(path)
52
-
52
+
53
53
  host = URI.parse(url).host
54
54
 
55
55
  auth_sign = sign("PUT", bucket_path, content_md5, content_type,date)
@@ -62,7 +62,7 @@ module CarrierWave
62
62
  "Expect" => "100-Continue"
63
63
  }
64
64
 
65
- RestClient.put(URI.encode(url).gsub("+", "%2B"), file, headers)
65
+ RestClient.put(url, file, headers)
66
66
  return path_to_url(path, :get => true)
67
67
  end
68
68
 
@@ -72,9 +72,20 @@ module CarrierWave
72
72
  # returns:
73
73
  # file data
74
74
  def get(path)
75
- path = format_path(path)
76
- url = path_to_url(path)
77
- RestClient.get(URI.encode(url))
75
+ path = format_path(path)
76
+ bucket_path = get_bucket_path(path)
77
+ date = gmtdate
78
+ url = path_to_url(path)
79
+ host = URI.parse(url).host
80
+ headers = {
81
+ "Host" => host,
82
+ "Date" => date,
83
+ "Authorization" => sign("GET", bucket_path, "", "" ,date)
84
+ }
85
+
86
+ # path = format_path(path)
87
+ # url = path_to_url(path)
88
+ RestClient.get(url, headers)
78
89
  end
79
90
 
80
91
  # 删除 Remote 的文件
@@ -95,8 +106,8 @@ module CarrierWave
95
106
  "Date" => date,
96
107
  "Authorization" => sign("DELETE", bucket_path, "", "" ,date)
97
108
  }
98
-
99
- RestClient.delete(URI.encode(url).gsub("+", "%2B"), headers)
109
+
110
+ RestClient.delete(url, headers)
100
111
  return path_to_url(path, :get => true)
101
112
  end
102
113
 
@@ -130,7 +141,7 @@ module CarrierWave
130
141
  private
131
142
  def sign(verb, path, content_md5 = '', content_type = '', date)
132
143
  canonicalized_oss_headers = ''
133
- canonicalized_resource = "/#{path}"
144
+ canonicalized_resource = "/#{URI.decode(path)}"
134
145
  string_to_sign = "#{verb}\n\n#{content_type}\n#{date}\n#{canonicalized_oss_headers}#{canonicalized_resource}"
135
146
  digest = OpenSSL::Digest.new('sha1')
136
147
  h = OpenSSL::HMAC.digest(digest, @aliyun_access_key, string_to_sign)
@@ -142,7 +153,7 @@ module CarrierWave
142
153
  class File < CarrierWave::SanitizedFile
143
154
  def initialize(uploader, base, path)
144
155
  @uploader = uploader
145
- @path = path
156
+ @path = URI.encode(path)
146
157
  @base = base
147
158
  end
148
159
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-aliyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-26 00:00:00.000000000 Z
11
+ date: 2015-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 2.4.7
85
+ rubygems_version: 2.4.8
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Aliyun OSS support for Carrierwave
@@ -93,4 +93,3 @@ test_files:
93
93
  - spec/foo.zip
94
94
  - spec/spec_helper.rb
95
95
  - spec/upload_spec.rb
96
- has_rdoc: