carrierwave-upyun 0.2.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/lib/carrierwave/storage/upyun.rb +25 -5
- metadata +11 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6915aa09ab9b7059d576c1dc6162cfaefd60ba5c48bcb4361724f321b43ebe93
|
4
|
+
data.tar.gz: 03af17a59f9c9aa13a742565c4e20c8c1c1c7a1df7726736c99047e21c8e2ca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6888113e3efb214f774fa9f28df17c16465c5b66aded6d35949b4fc5435a211c8a9129ebd4349bc4a6fb32d9ca23ca59711906810e485d3d49a096f97e3273b1
|
7
|
+
data.tar.gz: 357b98e4ff157f305d60843bbaa54d88bd7f1f19b66885ee127c724de44254b6ad1ce444dddc98ee7c230a5789a9546fbfadc1bd07e60cee6b374f27961321a2
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ gem 'carrierwave-upyun'
|
|
16
16
|
|
17
17
|
## Configuration
|
18
18
|
|
19
|
-
You'll need to configure the to use this in config/
|
19
|
+
You'll need to configure the to use this in config/initializers/carrierwave.rb
|
20
20
|
|
21
21
|
```ruby
|
22
22
|
CarrierWave.configure do |config|
|
@@ -16,7 +16,7 @@ module CarrierWave
|
|
16
16
|
#
|
17
17
|
class UpYun < Abstract
|
18
18
|
DEFAULT_API_URL = 'http://v0.api.upyun.com'
|
19
|
-
|
19
|
+
|
20
20
|
class File < CarrierWave::SanitizedFile
|
21
21
|
def initialize(uploader, base, path)
|
22
22
|
@uploader = uploader
|
@@ -34,7 +34,7 @@ module CarrierWave
|
|
34
34
|
def path
|
35
35
|
@path
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def escaped_path
|
39
39
|
@escaped_path ||= CGI.escape(@path)
|
40
40
|
end
|
@@ -102,9 +102,14 @@ module CarrierWave
|
|
102
102
|
# boolean
|
103
103
|
#
|
104
104
|
def store(data, headers = {})
|
105
|
-
conn.put(escaped_path, data) do |req|
|
105
|
+
res = conn.put(escaped_path, data) do |req|
|
106
106
|
req.headers = {'Expect' => '', 'Mkdir' => 'true'}.merge(headers)
|
107
107
|
end
|
108
|
+
if res.status != 200
|
109
|
+
puts "Update failed: #{res.body}"
|
110
|
+
return false
|
111
|
+
end
|
112
|
+
|
108
113
|
true
|
109
114
|
end
|
110
115
|
|
@@ -115,10 +120,10 @@ module CarrierWave
|
|
115
120
|
{}
|
116
121
|
end
|
117
122
|
end
|
118
|
-
|
123
|
+
|
119
124
|
def conn
|
120
125
|
return @conn if defined?(@conn)
|
121
|
-
|
126
|
+
|
122
127
|
api_host = @uploader.upyun_api_host || DEFAULT_API_URL
|
123
128
|
@conn = Faraday.new(url: "#{api_host}/#{@uploader.upyun_bucket}") do |req|
|
124
129
|
req.request :basic_auth, @uploader.upyun_username, @uploader.upyun_password
|
@@ -159,6 +164,21 @@ module CarrierWave
|
|
159
164
|
File.new(uploader, self, uploader.store_path(identifier))
|
160
165
|
end
|
161
166
|
|
167
|
+
def cache!(file)
|
168
|
+
f = File.new(uploader, self, uploader.store_path)
|
169
|
+
f.store(file.read, 'Content-Type' => file.content_type)
|
170
|
+
f
|
171
|
+
end
|
172
|
+
|
173
|
+
def retrieve_from_cache!(identifier)
|
174
|
+
File.new(uploader, self, uploader.cache_path(identifier))
|
175
|
+
end
|
176
|
+
|
177
|
+
def delete_dir!(path)
|
178
|
+
end
|
179
|
+
|
180
|
+
def clean_cache!(seconds)
|
181
|
+
end
|
162
182
|
end # CloudFiles
|
163
183
|
end # Storage
|
164
184
|
end # CarrierWave
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-upyun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nowa Zhu
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: carrierwave
|
@@ -17,14 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
20
|
+
version: 1.0.0
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '2.1'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
30
|
+
version: 1.0.0
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: faraday
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,8 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
146
|
- !ruby/object:Gem::Version
|
141
147
|
version: '0'
|
142
148
|
requirements: []
|
143
|
-
|
144
|
-
rubygems_version: 2.5.2
|
149
|
+
rubygems_version: 3.0.3
|
145
150
|
signing_key:
|
146
151
|
specification_version: 4
|
147
152
|
summary: UpYun Storage support for CarrierWave
|