activestorage_upyun 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_storage/service/upyun_service.rb +16 -7
- data/lib/activestorage_upyun/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73c80de02ef4e126bb4978f584f6be1cae119ea3b94607038e60bda1f7dbad88
|
4
|
+
data.tar.gz: 816fe2ceb51be81919920ae6926f7507ebb5c70976ba5ff5dd4f3d481590cf4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aead81d0973f6f46576ad8320face4cfc9e873eaed9c37db440b4c36da670d3b05cd4f1aba1b8adb2b1ed27e7a36c2dff606b800bb21c65d540bf54bc4ef54d4
|
7
|
+
data.tar.gz: 9e2cbd7adeef15f92ffed4d6f8086a44003572487525ab0b406aed781b9ae9fa70c5e985e0854fd76f0155322d20c948df981549d33f54a70d550361623c1105
|
@@ -37,7 +37,7 @@ module ActiveStorage
|
|
37
37
|
@upyun = Upyun::Rest.new(bucket, operator, password, options)
|
38
38
|
end
|
39
39
|
|
40
|
-
def upload(key, io, checksum: nil, content_type: nil, disposition: nil, filename: nil)
|
40
|
+
def upload(key, io, checksum: nil, content_type: nil, disposition: nil, filename: nil, custom_metadata: {}, **)
|
41
41
|
instrument :upload, key: key, checksum: checksum do
|
42
42
|
begin
|
43
43
|
result = @upyun.put(path_for(key), io)
|
@@ -89,7 +89,7 @@ module ActiveStorage
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:)
|
92
|
+
def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:, custom_metadata: {})
|
93
93
|
instrument :url, key: key do |payload|
|
94
94
|
url = [ENDPOINT, @bucket , @folder, key].join('/')
|
95
95
|
payload[:url] = url
|
@@ -97,7 +97,7 @@ module ActiveStorage
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
def headers_for_direct_upload(key, content_type:, checksum:,
|
100
|
+
def headers_for_direct_upload(key, content_type:, checksum:, custom_metadata: {}, **)
|
101
101
|
user = @operator
|
102
102
|
pwd = md5(@password)
|
103
103
|
method = 'PUT'
|
@@ -109,13 +109,22 @@ module ActiveStorage
|
|
109
109
|
OpenSSL::HMAC.digest('sha1', pwd, str)
|
110
110
|
)
|
111
111
|
auth = "UPYUN #{@operator}:#{signature}"
|
112
|
-
{
|
112
|
+
{
|
113
|
+
"Content-Type" => content_type,
|
114
|
+
"Authorization" => auth,
|
115
|
+
"X-Date" => date,
|
116
|
+
**custom_metadata_headers(custom_metadata)
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
def custom_metadata_headers(metadata)
|
121
|
+
metadata.transform_keys { |key| "x-upyun-meta-#{key}" }
|
113
122
|
end
|
114
123
|
|
115
124
|
def delete_prefixed(prefix)
|
116
125
|
instrument :delete_prefixed, prefix: prefix do
|
117
126
|
items = @upyun.getlist "/#{@folder}/#{prefix}"
|
118
|
-
|
127
|
+
if items.is_a?(Array)
|
119
128
|
items.each do |file|
|
120
129
|
@upyun.delete("/#{@folder}/#{prefix}#{file[:name]}")
|
121
130
|
end
|
@@ -129,7 +138,7 @@ module ActiveStorage
|
|
129
138
|
def url_for(key, params: {})
|
130
139
|
url = [@host, @folder, key].join('/')
|
131
140
|
return url if params.blank?
|
132
|
-
process = params.
|
141
|
+
process = params.dig(:process)
|
133
142
|
identifier = @upload_options[:identifier] || IDENTIFIER
|
134
143
|
url = [url, process].join(identifier) if process
|
135
144
|
url
|
@@ -140,7 +149,7 @@ module ActiveStorage
|
|
140
149
|
end
|
141
150
|
|
142
151
|
def fullpath(path)
|
143
|
-
decoded =
|
152
|
+
decoded = CGI.escape(CGI.unescape(path.to_s.force_encoding('utf-8')))
|
144
153
|
decoded = decoded.gsub('[', '%5B').gsub(']', '%5D')
|
145
154
|
"/#{@bucket}#{decoded.start_with?('/') ? decoded : '/' + decoded}"
|
146
155
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activestorage_upyun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- doabit
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activestorage
|
@@ -98,7 +98,7 @@ homepage: https://github.com/doabit/activestorage_upyun
|
|
98
98
|
licenses:
|
99
99
|
- MIT
|
100
100
|
metadata: {}
|
101
|
-
post_install_message:
|
101
|
+
post_install_message:
|
102
102
|
rdoc_options: []
|
103
103
|
require_paths:
|
104
104
|
- lib
|
@@ -113,9 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
|
117
|
-
|
118
|
-
signing_key:
|
116
|
+
rubygems_version: 3.5.22
|
117
|
+
signing_key:
|
119
118
|
specification_version: 4
|
120
119
|
summary: Upyun service for activestorage
|
121
120
|
test_files: []
|