azure-blob 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Rakefile +9 -0
- data/lib/active_storage/service/azure_blob_service.rb +16 -10
- data/lib/azure_blob/client.rb +20 -1
- data/lib/azure_blob/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd9cb1fb7e43ff7b01c0c1b751c4650be08107aaf134a6f9a5916b8671e9c067
|
4
|
+
data.tar.gz: 57b4c72aa7fd6f4f7d4e43b5b167de3ac6744d486d5e099728785fe7451b282e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dee84bb26174192109acfb4ac186d627c20ef54e2a3f2bb1b5ad36bcb04792c5805986ec63a805bdd4332975b3b18c45d9db75ab43f9ab3dfd42124ebdcca7b
|
7
|
+
data.tar.gz: 37080e6e53228b5bad0e70927abe736f8d769dcc90b7a93f9ac6d4480c269132f1f341fc47907a0b2e60c1741c235d57de09bf8d3b7a627ae4f9b0652c219c4e
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -20,6 +20,15 @@ end
|
|
20
20
|
task default: %i[test]
|
21
21
|
|
22
22
|
task :test do
|
23
|
+
[
|
24
|
+
"AZURE_ACCOUNT_NAME",
|
25
|
+
"AZURE_PRIVATE_CONTAINER",
|
26
|
+
"AZURE_PUBLIC_CONTAINER",
|
27
|
+
].each do |env|
|
28
|
+
value = ENV[env]
|
29
|
+
raise "#{env} variable need to be set if you are using the nix/devenv environment, consider running generate-env-file" if value.nil? || value.empty?
|
30
|
+
end
|
31
|
+
|
23
32
|
Rake::Task["test_client"].execute
|
24
33
|
Rake::Task["test_rails"].execute
|
25
34
|
end
|
@@ -123,16 +123,22 @@ module ActiveStorage
|
|
123
123
|
def compose(source_keys, destination_key, filename: nil, content_type: nil, disposition: nil, custom_metadata: {})
|
124
124
|
content_disposition = content_disposition_with(type: disposition, filename: filename) if disposition && filename
|
125
125
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
126
|
+
# use copy_blob operation if composing a new blob from a single existing blob
|
127
|
+
# and that single blob is <= 256 MiB which is the upper limit for copy_blob operation
|
128
|
+
if source_keys.length == 1 && client.get_blob_properties(source_keys[0]).size <= 256.megabytes
|
129
|
+
client.copy_blob(destination_key, source_keys[0], metadata: custom_metadata)
|
130
|
+
else
|
131
|
+
client.create_append_blob(
|
132
|
+
destination_key,
|
133
|
+
content_type: content_type,
|
134
|
+
content_disposition: content_disposition,
|
135
|
+
metadata: custom_metadata,
|
136
|
+
)
|
137
|
+
|
138
|
+
source_keys.each do |source_key|
|
139
|
+
stream(source_key) do |chunk|
|
140
|
+
client.append_blob_block(destination_key, chunk)
|
141
|
+
end
|
136
142
|
end
|
137
143
|
end
|
138
144
|
end
|
data/lib/azure_blob/client.rb
CHANGED
@@ -77,6 +77,25 @@ module AzureBlob
|
|
77
77
|
Http.new(uri, headers, signer:).get
|
78
78
|
end
|
79
79
|
|
80
|
+
# Copy a blob
|
81
|
+
#
|
82
|
+
# Calls to {Copy Blob From URL}[https://learn.microsoft.com/en-us/rest/api/storageservices/copy-blob-from-url]
|
83
|
+
#
|
84
|
+
# Takes a key (path) and a source_key (path).
|
85
|
+
#
|
86
|
+
def copy_blob(key, source_key, options = {})
|
87
|
+
uri = generate_uri("#{container}/#{key}")
|
88
|
+
|
89
|
+
source_uri = signed_uri(source_key, permissions: "r", expiry: Time.at(Time.now.to_i + 300).utc.iso8601)
|
90
|
+
|
91
|
+
headers = {
|
92
|
+
"x-ms-copy-source": source_uri.to_s,
|
93
|
+
"x-ms-requires-sync": "true",
|
94
|
+
}
|
95
|
+
|
96
|
+
Http.new(uri, headers, signer:, **options.slice(:metadata, :tags)).put
|
97
|
+
end
|
98
|
+
|
80
99
|
# Delete a blob
|
81
100
|
#
|
82
101
|
# Calls to {Delete Blob}[https://learn.microsoft.com/en-us/rest/api/storageservices/delete-blob]
|
@@ -202,7 +221,7 @@ module AzureBlob
|
|
202
221
|
uri = generate_uri(container)
|
203
222
|
headers = {}
|
204
223
|
headers[:"x-ms-blob-public-access"] = "blob" if options[:public_access]
|
205
|
-
headers[:"x-ms-blob-public-access"] = options[:public_access] if ["container","blob"].include?(options[:public_access])
|
224
|
+
headers[:"x-ms-blob-public-access"] = options[:public_access] if [ "container", "blob" ].include?(options[:public_access])
|
206
225
|
|
207
226
|
uri.query = URI.encode_www_form(restype: "container")
|
208
227
|
response = Http.new(uri, headers, signer:).put
|
data/lib/azure_blob/version.rb
CHANGED