carrierwave-upyun 1.0.5 → 2.0.0

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
  SHA256:
3
- metadata.gz: c3dbb71f891250bee0040c6601c39839250debac93b939750b50fad6311472f4
4
- data.tar.gz: 9ca44d2075031de26f9c99e32807bd3f1b2fcba94d7bb6310aa418963a51c84c
3
+ metadata.gz: ca61aedc9a8cba949a82c3506185ef2e9e0faec3ace731e0ed37d477e9c1b353
4
+ data.tar.gz: 73782b52b3d7a2a151990ee7f06b6369e2469d84136fb0c5e4482ed13814791a
5
5
  SHA512:
6
- metadata.gz: 6c18a685aac7bbb758d0dd2c6d8e086efa29673fc214e8054d44b8e05e620c147966e26fbc53a2c8c150ca0d76aa7d72190b52b28d0fa509b02863bcca619a42
7
- data.tar.gz: 980c9026cbd69f0219eb0292b2184a36d34ce04dfffd5694ef1a3fd7a5fdc69e1f882573cd9f711e4c410f5b8220e60e387b85b33449024b5cecdaf7b15e618e
6
+ metadata.gz: e4120deab7bc63594dcfddb9905efaf98c2f1342be1fe96522ae0d8d55559ac3af11595fb978035c47699432606b205b486ded93636647704e8a50ea98250a48
7
+ data.tar.gz: 8229e0db78f60f957289872e6ac2deb6a4397573d0be05bb501df4331b85c3667b9b3b5f9096d2c79ea959e2d59cfe468ba8648f6675da87284d562ab39956c7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.0.0
2
+
3
+ - Fix for support Faraday 2.x.
4
+
1
5
  ## 1.0.5
2
6
 
3
7
  - Fix carrierwave version dependency.
data/README.md CHANGED
@@ -7,9 +7,14 @@ This gem adds support for [upyun.com](http://www.upyun.com) to [CarrierWave](htt
7
7
 
8
8
  ## Installation
9
9
 
10
+ ```bash
11
+ $ bundle add carrierwave-upyun
12
+ ```
13
+
14
+ Or modify your Gemfile to add:
15
+
10
16
  ```ruby
11
- gem 'carrierwave'
12
- gem 'carrierwave-upyun'
17
+ gem "carrierwave-upyun"
13
18
  ```
14
19
 
15
20
  > NOTE: 此 Gem 是一个 CarrierWave 的组件,你需要配合 CarrierWave 一起使用。
@@ -24,8 +29,6 @@ CarrierWave.configure do |config|
24
29
  config.upyun_username = "xxxxxx"
25
30
  config.upyun_password = 'xxxxxx'
26
31
  config.upyun_bucket = "my_bucket"
27
- # upyun_bucket_domain 以后将会弃用,请改用 upyun_bucket_host
28
- # config.upyun_bucket_domain = "my_bucket.files.example.com"
29
32
  config.upyun_bucket_host = "http://my_bucket.files.example.com"
30
33
  end
31
34
  ```
@@ -24,12 +24,6 @@ module CarrierWave::Storage
24
24
  @escaped_path ||= CGI.escape(@path)
25
25
  end
26
26
 
27
- def content_type
28
- @content_type || ""
29
- end
30
-
31
- attr_writer :content_type
32
-
33
27
  ##
34
28
  # Reads the contents of the file from Cloud Files
35
29
  #
@@ -78,12 +72,13 @@ module CarrierWave::Storage
78
72
  # [NilClass] no file name available
79
73
  #
80
74
  def filename
81
- return unless file_url = url
82
- ::File.basename(file_url.split('?').first)
75
+ return unless url
76
+
77
+ ::File.basename(url.split("?").first)
83
78
  end
84
79
 
85
80
  def extension
86
- path_elements = path.split('.')
81
+ path_elements = path.split(".")
87
82
  path_elements.last if path_elements.size > 1
88
83
  end
89
84
 
@@ -111,7 +106,7 @@ module CarrierWave::Storage
111
106
  # [Integer] size of file body
112
107
  #
113
108
  def size
114
- headers['content-length'].to_i
109
+ headers["content-length"].to_i
115
110
  end
116
111
 
117
112
  ##
@@ -124,18 +119,18 @@ module CarrierWave::Storage
124
119
  def store(new_file, headers = {})
125
120
  # Copy from cache_path
126
121
  if new_file.is_a?(self.class)
127
- new_file.copy_to(self.escaped_path)
122
+ new_file.copy_to(escaped_path)
128
123
  return true
129
124
  end
130
125
 
131
- res = conn.put(self.escaped_path, new_file.read) do |req|
126
+ res = conn.put(escaped_path, new_file.read) do |req|
132
127
  req.headers = { "Expect" => "", "Mkdir" => "true" }.merge(headers)
133
128
  end
134
129
 
135
130
  check_put_response!(res)
136
131
 
137
132
  true
138
- rescue ConcurrentUploadError => e
133
+ rescue ConcurrentUploadError
139
134
  retry
140
135
  end
141
136
 
@@ -151,19 +146,18 @@ module CarrierWave::Storage
151
146
  # @return [CarrierWave::Storage::UpYun::File] the location where the file will be stored.
152
147
  #
153
148
  def copy_to(new_path)
154
- escaped_new_path = CGI.escape(new_path)
155
149
  res = conn.put(new_path) do |req|
156
150
  req.headers = {
157
- "X-Upyun-Copy-Source" => "/#{@uploader.upyun_bucket}/#{self.path}",
151
+ "X-Upyun-Copy-Source" => "/#{@uploader.upyun_bucket}/#{path}",
158
152
  "Content-Length" => 0,
159
- "Mkdir" => "true",
153
+ "Mkdir" => "true"
160
154
  }
161
155
  end
162
156
 
163
157
  check_put_response!(res)
164
158
 
165
159
  File.new(@uploader, @base, new_path)
166
- rescue ConcurrentUploadError => e
160
+ rescue ConcurrentUploadError
167
161
  retry
168
162
  end
169
163
 
@@ -184,14 +178,12 @@ module CarrierWave::Storage
184
178
  @conn ||= begin
185
179
  api_host = @uploader.upyun_api_host || DEFAULT_API_URL
186
180
  Faraday.new(url: "#{api_host}/#{@uploader.upyun_bucket}") do |req|
187
- req.request :basic_auth, @uploader.upyun_username, @uploader.upyun_password
181
+ req.request :authorization, :basic, @uploader.upyun_username, @uploader.upyun_password
188
182
  req.request :url_encoded
189
183
  req.adapter Faraday.default_adapter
190
184
  end
191
185
  end
192
186
  end
193
-
194
-
195
187
  end
196
188
  end
197
- end
189
+ end
@@ -19,6 +19,7 @@ module CarrierWave
19
19
  DEFAULT_API_URL = "http://v0.api.upyun.com"
20
20
 
21
21
  class UploadError < RuntimeError; end
22
+
22
23
  class ConcurrentUploadError < RuntimeError; end
23
24
 
24
25
  ##
@@ -62,9 +63,11 @@ module CarrierWave
62
63
  File.new(uploader, self, uploader.cache_path(identifier))
63
64
  end
64
65
 
65
- def delete_dir!(path); end
66
+ def delete_dir!(path)
67
+ end
66
68
 
67
- def clean_cache!(seconds); end
68
- end # CloudFiles
69
- end # Storage
70
- end # CarrierWave
69
+ def clean_cache!(seconds)
70
+ end
71
+ end
72
+ end
73
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-upyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nowa Zhu
8
8
  - Jason Lee
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-07 00:00:00.000000000 Z
12
+ date: 2022-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: carrierwave
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 0.8.0
34
+ version: '2.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 0.8.0
41
+ version: '2.0'
42
42
  description: UpYun Storage support for CarrierWave
43
43
  email:
44
44
  - nowazhu@gmail.com
@@ -56,7 +56,7 @@ files:
56
56
  homepage: https://github.com/nowa/carrierwave-upyun
57
57
  licenses: []
58
58
  metadata: {}
59
- post_install_message:
59
+ post_install_message:
60
60
  rdoc_options: []
61
61
  require_paths:
62
62
  - lib
@@ -71,8 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 3.0.3
75
- signing_key:
74
+ rubygems_version: 3.3.3
75
+ signing_key:
76
76
  specification_version: 4
77
77
  summary: UpYun Storage support for CarrierWave
78
78
  test_files: []