activestorage-openstack 1.1.0 → 1.4.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cce4c99f0a5a3c5cbdef328ae3633196657a04a8c9ba801fe82904b1f0283abf
|
4
|
+
data.tar.gz: 2cf3bcee0842a884a11ae611e7c39cd0a059e690cb2f9872e647999274b68490
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a467d3b91dd8c2be7cad76e02f223b43bb4ccbe82b26b19459fb9388f7c21e2e5d31ce051ab325d225159c377157fb96d3701d58b2e0b870edeb4aea5ea2660
|
7
|
+
data.tar.gz: a4ee1f33629ee2ad84ccba999290f27c495a412e867242a97ff5952e2dde22baab641ad1600db2afa47b2aa671f6a22917a79cd576168cd38bf349b246923788
|
@@ -1,18 +1,6 @@
|
|
1
1
|
module ActiveStorage
|
2
2
|
module Openstack
|
3
3
|
class Railtie < ::Rails::Railtie
|
4
|
-
initializer "active_storage_openstack.blob" do
|
5
|
-
ActiveSupport.on_load(:active_storage_blob) do |klass|
|
6
|
-
klass.after_commit do |blob|
|
7
|
-
# overwrite content type if identification run and
|
8
|
-
# the service responds to change_content_type
|
9
|
-
if blob.identified? && !blob.content_type.blank? &&
|
10
|
-
blob.service.respond_to?(:change_content_type)
|
11
|
-
blob.service.change_content_type(blob.key, blob.content_type)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
4
|
end
|
17
5
|
end
|
18
6
|
end
|
@@ -11,10 +11,14 @@ module ActiveStorage
|
|
11
11
|
@container = Fog::OpenStack.escape(container)
|
12
12
|
end
|
13
13
|
|
14
|
-
def upload(key, io, checksum: nil, **)
|
14
|
+
def upload(key, io, checksum: nil, disposition: nil, content_type: nil, filename: nil, **)
|
15
15
|
instrument :upload, key: key, checksum: checksum do
|
16
|
-
params = { 'Content-Type' => guess_content_type(io) }
|
16
|
+
params = { 'Content-Type' => content_type || guess_content_type(io) }
|
17
17
|
params['ETag'] = convert_base64digest_to_hexdigest(checksum) if checksum
|
18
|
+
if disposition && filename
|
19
|
+
params['Content-Disposition'] =
|
20
|
+
content_disposition_with(type: disposition, filename: filename)
|
21
|
+
end
|
18
22
|
|
19
23
|
begin
|
20
24
|
client.put_object(container, key, io, params)
|
@@ -35,7 +39,7 @@ module ActiveStorage
|
|
35
39
|
end
|
36
40
|
end
|
37
41
|
rescue Fog::OpenStack::Storage::NotFound
|
38
|
-
raise ActiveStorage::FileNotFoundError
|
42
|
+
raise ActiveStorage::FileNotFoundError if defined?(ActiveStorage::FileNotFoundError)
|
39
43
|
end
|
40
44
|
|
41
45
|
def download_chunk(key, range)
|
@@ -48,16 +52,15 @@ module ActiveStorage
|
|
48
52
|
|
49
53
|
chunk_buffer.join[range]
|
50
54
|
rescue Fog::OpenStack::Storage::NotFound
|
51
|
-
raise ActiveStorage::FileNotFoundError
|
55
|
+
raise ActiveStorage::FileNotFoundError if defined?(ActiveStorage::FileNotFoundError)
|
52
56
|
end
|
53
57
|
end
|
58
|
+
|
54
59
|
def delete(key)
|
55
60
|
instrument :delete, key: key do
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
false
|
60
|
-
end
|
61
|
+
client.delete_object(container, key)
|
62
|
+
rescue Fog::OpenStack::Storage::NotFound
|
63
|
+
false
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
@@ -73,12 +76,10 @@ module ActiveStorage
|
|
73
76
|
|
74
77
|
def exist?(key)
|
75
78
|
instrument :exist, key: key do |payload|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
payload[:exist] = false
|
81
|
-
end
|
79
|
+
answer = head_for(key)
|
80
|
+
payload[:exist] = answer.present?
|
81
|
+
rescue Fog::OpenStack::Storage::NotFound
|
82
|
+
payload[:exist] = false
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
@@ -91,7 +92,7 @@ module ActiveStorage
|
|
91
92
|
key,
|
92
93
|
expire_at,
|
93
94
|
filename: filename
|
94
|
-
|
95
|
+
)
|
95
96
|
generated_url += '&inline' if disposition.to_s != 'attachment'
|
96
97
|
# unfortunately OpenStack Swift cannot overwrite the content type of an object via a temp url
|
97
98
|
# so we just ignore the content_type argument here
|
@@ -124,18 +125,28 @@ module ActiveStorage
|
|
124
125
|
}
|
125
126
|
end
|
126
127
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
128
|
+
def update_metadata(key, content_type:, disposition: nil, filename: nil, **)
|
129
|
+
instrument :update_metadata, key: key, content_type: content_type, disposition: disposition do
|
130
|
+
params = { 'Content-Type' => content_type }
|
131
|
+
if disposition && filename
|
132
|
+
params['Content-Disposition'] =
|
133
|
+
content_disposition_with(type: disposition, filename: ActiveStorage::Filename.wrap(filename))
|
134
|
+
end
|
135
|
+
client.post_object(container,
|
136
|
+
key,
|
137
|
+
params)
|
138
|
+
true
|
139
|
+
rescue Fog::OpenStack::Storage::NotFound
|
140
|
+
raise ActiveStorage::FileNotFoundError if defined?(ActiveStorage::FileNotFoundError)
|
141
|
+
end
|
135
142
|
end
|
136
143
|
|
137
144
|
private
|
138
145
|
|
146
|
+
def head_for(key)
|
147
|
+
client.head_object(container, key)
|
148
|
+
end
|
149
|
+
|
139
150
|
def object_for(key, &block)
|
140
151
|
client.get_object(container, key, &block)
|
141
152
|
end
|
@@ -143,7 +154,7 @@ module ActiveStorage
|
|
143
154
|
# ActiveStorage sends a `Digest::MD5.base64digest` checksum
|
144
155
|
# OpenStack expects a `Digest::MD5.hexdigest` ETag
|
145
156
|
def convert_base64digest_to_hexdigest(base64digest)
|
146
|
-
base64digest.
|
157
|
+
base64digest.unpack1('m0').unpack1('H*')
|
147
158
|
end
|
148
159
|
|
149
160
|
def unix_timestamp_expires_at(seconds_from_now)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activestorage-openstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chedli Bourguiba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-openstack
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 5.2.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 5.2.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sqlite3
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: 1.8.11
|
144
144
|
requirements: []
|
145
|
-
rubygems_version: 3.
|
145
|
+
rubygems_version: 3.1.3
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: ActiveStorage wrapper for OpenStack Storage
|