Skip to content

Commit 674fe68

Browse files
committed
chore: revert to using copy blob from url option and update changelog
1 parent 9e1bbbe commit 674fe68

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## [Unreleased]
22

3+
- Add `copy_blob`
4+
- Update `compose` to use `copy_blob` if 1 source key and blob is <= 256MiB
5+
36
## [0.5.6] 2025-01-17
47

58
- Fix user delegation key not refreshing (#14)

lib/active_storage/service/azure_blob_service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def compose(source_keys, destination_key, filename: nil, content_type: nil, disp
124124
content_disposition = content_disposition_with(type: disposition, filename: filename) if disposition && filename
125125

126126
# use copy_blob operation if composing a new blob from a single existing blob
127-
# and that single blob is <= 5000 MiB which is the upper limit for copy_blob operation
128-
if source_keys.length == 1 && client.get_blob_properties(source_keys[0]).size <= 5000.megabytes
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
129129
client.copy_blob(destination_key, source_keys[0], metadata: custom_metadata)
130130
else
131131
client.create_append_blob(

lib/azure_blob/client.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_blob(key, options = {})
7979

8080
# Copy a blob
8181
#
82-
# Calls to {Put Blob From URL}[https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob-from-url]
82+
# Calls to {Put Blob From URL}[https://learn.microsoft.com/en-us/rest/api/storageservices/copy-blob-from-url]
8383
#
8484
# Takes a key (path) and a source_key (path).
8585
#
@@ -89,9 +89,8 @@ def copy_blob(key, source_key, options = {})
8989
source_uri = signed_uri(source_key, permissions: "r", expiry: Time.at(Time.now.to_i + 300).utc.iso8601)
9090

9191
headers = {
92-
"Content-Length": 0,
9392
"x-ms-copy-source": source_uri.to_s,
94-
"x-ms-blob-type": "BlockBlob",
93+
"x-ms-requires-sync": "true",
9594
}
9695

9796
Http.new(uri, headers, signer:, **options.slice(:metadata, :tags)).put

0 commit comments

Comments
 (0)