Class: Azure::Blob::BlobService
- Inherits:
-
Service::StorageService
- Object
- Core::SignedService
- Service::StorageService
- Azure::Blob::BlobService
- Defined in:
- lib/azure/blob/blob_service.rb
Instance Method Summary collapse
-
#acquire_lease(container, blob, options = {}) ⇒ Object
Public: Establishes an exclusive one-minute write lock on a blob.
-
#break_lease(container, blob, options = {}) ⇒ Object
Public: Breaks the lease, if the blob has an active lease.
- #call(method, uri, body = nil, headers = nil) ⇒ Object
-
#clear_blob_pages(container, blob, start_range, end_range, options = {}) ⇒ Object
Public: Clears a range of pages from the blob.
-
#commit_blob_blocks(container, blob, block_list, options = {}) ⇒ Object
Public: Commits existing blob blocks to a blob.
-
#copy_blob(destination_container, destination_blob, source_container, source_blob, options = {}) ⇒ Object
Public: Copies a source blob to a destination blob within the same storage account.
-
#create_blob_block(container, blob, block_id, content, options = {}) ⇒ Object
Public: Creates a new block to be committed as part of a block blob.
-
#create_blob_pages(container, blob, start_range, end_range, content, options = {}) ⇒ Object
Public: Creates a range of pages in a page blob.
-
#create_blob_snapshot(container, blob, options = {}) ⇒ Object
Public: Creates a snapshot of a blob.
-
#create_block_blob(container, blob, content, options = {}) ⇒ Object
Public: Creates a new block blob or updates the content of an existing block blob.
-
#create_container(name, options = {}) ⇒ Object
Public: Create a new container.
-
#create_page_blob(container, blob, length, options = {}) ⇒ Object
Public: Creates a new page blob.
-
#delete_blob(container, blob, options = {}) ⇒ Object
Public: Deletes a blob or blob snapshot.
-
#delete_container(name, options = {}) ⇒ Object
Public: Deletes a container.
-
#get_blob(container, blob, options = {}) ⇒ Object
Public: Reads or downloads a blob from the system, including its metadata and properties.
-
#get_blob_metadata(container, blob, options = {}) ⇒ Object
Public: Returns metadata on the blob.
-
#get_blob_properties(container, blob, options = {}) ⇒ Object
Public: Returns all properties and metadata on the blob.
-
#get_container_acl(name, options = {}) ⇒ Object
Public: Gets the access control list (ACL) and any container-level access policies for the container.
-
#get_container_metadata(name, options = {}) ⇒ Object
Public: Returns only user-defined metadata for the specified container.
-
#get_container_properties(name, options = {}) ⇒ Object
Public: Returns all properties and metadata on the container.
-
#initialize(options = {}) ⇒ BlobService
constructor
A new instance of BlobService.
-
#list_blob_blocks(container, blob, options = {}) ⇒ Object
Public: Retrieves the list of blocks that have been uploaded as part of a block blob.
-
#list_blobs(name, options = {}) ⇒ Object
Public: Get a list of Blobs from the server.
-
#list_containers(options = {}) ⇒ Object
Public: Get a list of Containers from the server.
-
#list_page_blob_ranges(container, blob, options = {}) ⇒ Object
Public: Returns a list of active page ranges for a page blob.
-
#release_lease(container, blob, lease, options = {}) ⇒ Object
Public: Releases the lease.
-
#renew_lease(container, blob, lease, options = {}) ⇒ Object
Public: Renews the lease.
-
#set_blob_metadata(container, blob, metadata, options = {}) ⇒ Object
Public: Sets metadata headers on the blob.
-
#set_blob_properties(container, blob, options = {}) ⇒ Object
Public: Sets system properties defined for a blob.
-
#set_container_acl(name, public_access_level, options = {}) ⇒ Object
Public: Sets the ACL and any container-level access policies for the container.
-
#set_container_metadata(name, metadata, options = {}) ⇒ Object
Public: Sets custom metadata for the container.
Methods inherited from Service::StorageService
#add_metadata_to_headers, #get_service_properties, #service_properties_headers, #service_properties_uri, #set_service_properties
Constructor Details
#initialize(options = {}) ⇒ BlobService
Returns a new instance of BlobService.
24 25 26 27 28 29 30 |
# File 'lib/azure/blob/blob_service.rb', line 24 def initialize( = {}) client_config = [:client] || Azure signer = [:signer] || Azure::Core::Auth::SharedKey.new(client_config.storage_account_name, client_config.storage_access_key) super(signer, client_config.storage_account_name, ) @host = client.storage_blob_host end |
Instance Method Details
#acquire_lease(container, blob, options = {}) ⇒ Object
Public: Establishes an exclusive one-minute write lock on a blob. To write to a locked blob, a client must provide a lease ID.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:duration
- Integer. Default -1. Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. (optional) -
:proposed_lease_id
- String. Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) if the proposed lease ID is not in the correct format. (optional) -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/ee691972.aspx
Returns a String of the new unique lease id. While the lease is active, you must include the lease ID with any request to write to the blob, or to renew, change, or release the lease. A successful renew operation also returns the lease id for the active lease.
1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 |
# File 'lib/azure/blob/blob_service.rb', line 1237 def acquire_lease(container, blob, ={}) query = { 'comp' => 'lease'} query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) duration = -1 duration = [:duration] if [:duration] headers = service_properties_headers headers['x-ms-lease-action'] = 'acquire' headers['x-ms-lease-duration'] = duration.to_s if duration headers['x-ms-proposed-lease-id'] = [:proposed_lease_id] if [:proposed_lease_id] response = call(:put, uri, nil, headers) response.headers['x-ms-lease-id'] end |
#break_lease(container, blob, options = {}) ⇒ Object
Public: Breaks the lease, if the blob has an active lease. Once a lease is broken, it cannot be renewed. Any authorized request can break the lease; the request is not required to specify a matching lease ID. When a lease is broken, the lease break period is allowed to elapse, during which time no lease operation except break and release can be performed on the blob. When a lease is successfully broken, the response indicates the interval in seconds until a new lease can be acquired.
A lease that has been broken can also be released, in which case another client may immediately acquire the lease on the blob.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:break_period
- Integer. The proposed duration of seconds that the lease should continue before it is broken, between 0 and 60 seconds. This break period is only used if it is shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease will not be available before the break period has expired, but the lease may be held for longer than the break period.If this option is not used, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks immediately.
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/ee691972.aspx
Returns an Integer of the remaining lease time. This value is the approximate time remaining in the lease period, in seconds. This header is returned only for a successful request to break the lease. If the break is immediate, 0 is returned.
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 |
# File 'lib/azure/blob/blob_service.rb', line 1355 def break_lease(container, blob, ={}) query = { 'comp' => 'lease'} query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers headers['x-ms-lease-action'] = 'break' headers['x-ms-lease-break-period'] = [:break_period].to_s if [:break_period] response = call(:put, uri, nil, headers) response.headers['x-ms-lease-time'].to_i end |
#call(method, uri, body = nil, headers = nil) ⇒ Object
1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 |
# File 'lib/azure/blob/blob_service.rb', line 1369 def call(method, uri, body=nil, headers=nil) # Synchronize body and header encoding; header['Content-Encoding'] takes precedence. if headers && !body.nil? if headers['Content-Encoding'].nil? headers['Content-Encoding'] = body.encoding.to_s if body.respond_to? :encoding # String headers['Content-Encoding'] = body.external_encoding.to_s if body.respond_to? :external_encoding # IO else body.force_encoding(headers['Content-Encoding']) if body.respond_to? :force_encoding # String body.set_encoding(headers['Content-Encoding']) if body.respond_to? :set_encoding # IO end # Azure Storage Service expects content-encoding to be lowercase. # Authentication will fail otherwise. headers['Content-Encoding'] = headers['Content-Encoding'].downcase end response = super # Force the response.body to the content encoding of specified in the header. # content-encoding is echo'd back for the blob and is used to store the encoding of the octet stream if !response.nil? && !response.body.nil? && response.headers['content-encoding'] response.body.force_encoding(response.headers['content-encoding']) end response end |
#clear_blob_pages(container, blob, start_range, end_range, options = {}) ⇒ Object
Public: Clears a range of pages from the blob.
Attributes
-
container
- String. Name of container. -
blob
- String. Name of blob. -
start_range
- Integer. Position of first byte of first page. -
end_range
- Integer. Position of last byte of of last page. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/ee691975.aspx
Returns Blob
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'lib/azure/blob/blob_service.rb', line 528 def clear_blob_pages(container, blob, start_range, end_range, ={}) query = { 'comp' => 'page'} query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers headers['x-ms-range'] = "bytes=#{start_range}-#{end_range}" headers['x-ms-page-write'] = 'clear' # clear default content type headers['Content-Type'] = '' response = call(:put, uri, nil, headers) result = Serialization.blob_from_headers(response.headers) result.name = blob result end |
#commit_blob_blocks(container, blob, block_list, options = {}) ⇒ Object
Public: Commits existing blob blocks to a blob.
This method writes a blob by specifying the list of block IDs that make up the blob. In order to be written as part of a blob, a block must have been successfully written to the server in a prior create_blob_block method.
You can call Put Block List to update a blob by uploading only those blocks that have changed, then committing the new and existing blocks together. You can do this by specifying whether to commit a block from the committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the block, whichever list it may belong to.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
block_list
- Array. A ordered list of lists in the following format:- [“block_id1”, :committed], [“block_id2”, :uncommitted], [“block_id3”], [“block_id4”, :committed]…
-
The first element of the inner list is the block_id, the second is optional and can be either :committed or :uncommitted to indicate in which group of blocks the id should be looked for. If it is omitted, the latest of either group will be used.
-
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:content_md5
- String. Content MD5 for the request contents (not the blob contents!) -
:blob_content_type
- String. Content type for the blob. Will be saved with blob. -
:blob_content_encoding
- String. Content encoding for the blob. Will be saved with blob. -
:blob_content_language
- String. Content language for the blob. Will be saved with blob. -
:blob_content_md5
- String. Content MD5 for the blob. Will be saved with blob. -
:blob_cache_control
- String. Cache control for the blob. Will be saved with blob. -
:metadata
- Hash. Custom metadata values to store with the blob. -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179467.aspx
Returns nil on success
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
# File 'lib/azure/blob/blob_service.rb', line 693 def commit_blob_blocks(container, blob, block_list, ={}) query = { 'comp' => 'blocklist'} query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers unless .empty? headers['Content-MD5'] = [:content_md5] if [:content_md5] headers['x-ms-blob-content-type'] = [:blob_content_type] if [:blob_content_type] headers['x-ms-blob-content-encoding'] = [:blob_content_encoding] if [:blob_content_encoding] headers['x-ms-blob-content-language'] = [:blob_content_language] if [:blob_content_language] headers['x-ms-blob-content-md5'] = [:blob_content_md5] if [:blob_content_md5] headers['x-ms-blob-cache-control'] = [:blob_cache_control] if [:blob_cache_control] headers['x-ms-blob-content-disposition'] = [:blob_content_disposition] if [:blob_content_disposition] ([:metadata], headers) if [:metadata] end body = Serialization.block_list_to_xml(block_list) call(:put, uri, body, headers) nil end |
#copy_blob(destination_container, destination_blob, source_container, source_blob, options = {}) ⇒ Object
Public: Copies a source blob to a destination blob within the same storage account.
Attributes
-
source_container
- String. The destination container name to copy to. -
source_blob
- String. The destination blob name to copy to. -
destination_container
- String. The source container name to copy from. -
destination_blob
- String. The source blob name to copy from. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:source_snapshot
- String. A snapshot id for the source blob -
:metadata
- Hash. Custom metadata values to store with the copy. If this parameter is not specified, the operation will copy the source blob metadata to the destination blob. If this parameter is specified, the destination blob is created with the specified metadata, and metadata is not copied from the source blob. -
:source_if_modified_since
- A DateTime value. Specify this option to write the page only if the source blob has been modified since the specified date/time. If the blob has not been modified, the Blob service returns status code 412 (Precondition Failed). -
:source_if_unmodified_since
- A DateTime value. Specify this option to write the page only if the source blob has not been modified since the specified date/time. If the blob has been modified, the Blob service returns status code 412 (Precondition Failed). -
:source_if_match
- An ETag value. Specify an ETag value to write the page only if the source blob’s ETag value matches the value specified. If the values do not match, the Blob service returns status code 412 (Precondition Failed). -
:source_if_none_match
- An ETag value. Specify an ETag value to write the page only if the source blob’s ETag value does not match the value specified. If the values are identical, the Blob service returns status code 412 (Precondition Failed). -
:dest_if_modified_since
- A DateTime value. Specify this option to write the page only if the destination blob has been modified since the specified date/time. If the blob has not been modified, the Blob service returns status code 412 (Precondition Failed). -
:dest_if_unmodified_since
- A DateTime value. Specify this option to write the page only if the destination blob has not been modified since the specified date/time. If the blob has been modified, the Blob service returns status code 412 (Precondition Failed). -
:dest_if_match
- An ETag value. Specify an ETag value to write the page only if the destination blob’s ETag value matches the value specified. If the values do not match, the Blob service returns status code 412 (Precondition Failed). -
:dest_if_none_match
- An ETag value. Specify an ETag value to write the page only if the destination blob’s ETag value does not match the value specified. If the values are identical, the Blob service returns status code 412 (Precondition Failed). -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd894037.aspx
Returns a tuple of (copy_id, copy_status).
-
copy_id
- String identifier for this copy operation. Use with get_blob or get_blob_properties to check the status of this copy operation, or pass to abort_copy_blob to abort a pending copy. -
copy_status
- String. The state of the copy operation, with these values: “success” - The copy completed successfully. “pending” - The copy is in progress.
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 |
# File 'lib/azure/blob/blob_service.rb', line 1188 def copy_blob(destination_container, destination_blob, source_container, source_blob, ={}) query = { } query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(destination_container, destination_blob, query) headers = service_properties_headers headers['x-ms-copy-source'] = blob_uri(source_container, source_blob, [:source_snapshot] ? { 'snapshot' => [:source_snapshot] } : {}).to_s unless .empty? headers['If-Modified-Since'] = [:dest_if_modified_since] if [:dest_if_modified_since] headers['If-Unmodified-Since'] = [:dest_if_unmodified_since] if [:dest_if_unmodified_since] headers['If-Match'] = [:dest_if_match] if [:dest_if_match] headers['If-None-Match'] = [:dest_if_none_match] if [:dest_if_none_match] headers['x-ms-source-if-modified-since'] = [:source_if_modified_since] if [:source_if_modified_since] headers['x-ms-source-if-unmodified-since'] = [:source_if_unmodified_since] if [:source_if_unmodified_since] headers['x-ms-source-if-match'] = [:source_if_match] if [:source_if_match] headers['x-ms-source-if-none-match'] = [:source_if_none_match] if [:source_if_none_match] ([:metadata], headers) if [:metadata] end response = call(:put, uri, nil, headers) return response.headers['x-ms-copy-id'], response.headers['x-ms-copy-status'] end |
#create_blob_block(container, blob, block_id, content, options = {}) ⇒ Object
Public: Creates a new block to be committed as part of a block blob.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
block_id
- String. The block id. Note: this should be the raw block id, not Base64 encoded. -
content
- IO or String. The content of the blob. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:content_md5
- String. Content MD5 for the request contents. -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd135726.aspx
Returns the MD5 of the uploaded block (as calculated by the server)
640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/azure/blob/blob_service.rb', line 640 def create_blob_block(container, blob, block_id, content, ={}) query = { 'comp' => 'block'} query['blockid'] = Base64.strict_encode64(block_id) query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers headers['Content-MD5'] = [:content_md5] if [:content_md5] response = call(:put, uri, content, headers) response.headers['Content-MD5'] end |
#create_blob_pages(container, blob, start_range, end_range, content, options = {}) ⇒ Object
Public: Creates a range of pages in a page blob.
Attributes
-
container
- String. Name of container -
blob
- String. Name of blob -
start_range
- Integer. Position of first byte of first page -
end_range
- Integer. Position of last byte of of last page -
content
- IO or String. Content to write. Length in bytes should equal end_range - start_range -
options
- Hash. A collection of options.
Options
Accepted key/value pairs in options parameter are:
-
:if_sequence_number_le
- If the blob’s sequence number is less than or equal to the specified value, the request proceeds; otherwise it fails with the SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed). -
:if_sequence_number_lt
- If the blob’s sequence number is less than the specified value, the request proceeds; otherwise it fails with SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed). -
:if_sequence_number_eq
- If the blob’s sequence number is equal to the specified value, the request proceeds; otherwise it fails with SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed). -
:if_modified_since
- A DateTime value. Specify this conditional header to write the page only if the blob has been modified since the specified date/time. If the blob has not been modified, the Blob service returns status code 412 (Precondition Failed). -
:if_unmodified_since
- A DateTime value. Specify this conditional header to write the page only if the blob has not been modified since the specified date/time. If the blob has been modified, the Blob service returns status code 412 (Precondition Failed). -
:if_match
- An ETag value. Specify an ETag value for this conditional header to write the page only if the blob’s ETag value matches the value specified. If the values do not match, the Blob service returns status code 412 (Precondition Failed). -
:if_none_match
- An ETag value. Specify an ETag value for this conditional header to write the page only if the blob’s ETag value does not match the value specified. If the values are identical, the Blob service returns status code 412 (Precondition Failed). -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/ee691975.aspx
Returns Blob
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/azure/blob/blob_service.rb', line 479 def create_blob_pages(container, blob, start_range, end_range, content, ={}) query = { 'comp' => 'page'} query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers headers['x-ms-range'] = "bytes=#{start_range}-#{end_range}" headers['x-ms-page-write'] = 'update' # clear default content type headers['Content-Type'] = '' # set optional headers unless .empty? headers['x-ms-if-sequence-number-le'] = [:if_sequence_number_le] if [:if_sequence_number_le] headers['x-ms-if-sequence-number-lt'] = [:if_sequence_number_lt] if [:if_sequence_number_lt] headers['x-ms-if-sequence-number-eq'] = [:if_sequence_number_eq] if [:if_sequence_number_eq] headers['If-Modified-Since'] = [:if_modified_since] if [:if_modified_since] headers['If-Unmodified-Since'] = [:if_unmodified_since] if [:if_unmodified_since] headers['If-Match'] = [:if_match] if [:if_match] headers['If-None-Match'] = [:if_none_match] if [:if_none_match] end response = call(:put, uri, content, headers) result = Serialization.blob_from_headers(response.headers) result.name = blob result end |
#create_blob_snapshot(container, blob, options = {}) ⇒ Object
Public: Creates a snapshot of a blob.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:metadata
- Hash. Custom metadata values to store with the blob snapshot. -
:if_modified_since
- A DateTime value. Specify this option to write the page only if the blob has been modified since the specified date/time. If the blob has not been modified, the Blob service returns status code 412 (Precondition Failed). -
:if_unmodified_since
- A DateTime value. Specify this option to write the page only if the blob has not been modified since the specified date/time. If the blob has been modified, the Blob service returns status code 412 (Precondition Failed). -
:if_match
- An ETag value. Specify an ETag value to write the page only if the blob’s ETag value matches the value specified. If the values do not match, the Blob service returns status code 412 (Precondition Failed). -
:if_none_match
- An ETag value. Specify an ETag value to write the page only if the blob’s ETag value does not match the value specified. If the values are identical, the Blob service returns status code 412 (Precondition Failed). -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/ee691971.aspx
Returns the snapshot DateTime value
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
# File 'lib/azure/blob/blob_service.rb', line 1113 def create_blob_snapshot(container, blob, ={}) query = { 'comp' => 'snapshot'} query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers unless .empty? ([:metadata], headers) if [:metadata] headers['If-Modified-Since'] = [:if_modified_since] if [:if_modified_since] headers['If-Unmodified-Since'] = [:if_unmodified_since] if [:if_unmodified_since] headers['If-Match'] = [:if_match] if [:if_match] headers['If-None-Match'] = [:if_none_match] if [:if_none_match] end response = call(:put, uri, nil, headers) response.headers['x-ms-snapshot'] end |
#create_block_blob(container, blob, content, options = {}) ⇒ Object
Public: Creates a new block blob or updates the content of an existing block blob.
Updating an existing block blob overwrites any existing metadata on the blob Partial updates are not supported with create_block_blob the content of the existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a block blob, use the create_block_list method.
Note that the default content type is application/octet-stream.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
content
- IO or String. The content of the blob. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:content_type
- String. Content type for the request. Will be saved with blob unless alternate value is provided in blob_content_type. -
:content_encoding
- String. Content encoding for the request. Will be saved with blob unless alternate value is provided in blob_content_encoding. -
:content_language
- String. Content language for the request. Will be saved with blob unless alternate value is provided in blob_content_language. -
:content_md5
- String. Content MD5 for the request. Will be saved with blob unless alternate value is provided in blob_content_md5. -
:cache_control
- String. Cache control for the request. Will be saved with blob unless alternate value is provided in blob_cache_control. -
:blob_content_type
- String. Content type for the blob. Will be saved with blob. -
:blob_content_encoding
- String. Content encoding for the blob. Will be saved with blob. -
:blob_content_language
- String. Content language for the blob. Will be saved with blob. -
:blob_content_md5
- String. Content MD5 for the blob. Will be saved with blob. -
:blob_cache_control
- String. Cache control for the blob. Will be saved with blob. -
:metadata
- Hash. Custom metadata values to store with the blob. -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179451.aspx
Returns a Blob
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/azure/blob/blob_service.rb', line 585 def create_block_blob(container, blob, content, ={}) query = { } query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers # set x-ms-blob-type to BlockBlob headers['x-ms-blob-type'] = 'BlockBlob' # set the rest of the optional headers headers['Content-Type'] = [:content_type] || 'application/octet-stream' headers['Content-Encoding'] = [:content_encoding] if [:content_encoding] headers['Content-Language'] = [:content_language] if [:content_language] headers['Content-MD5'] = [:content_md5] if [:content_md5] headers['Cache-Control'] = [:cache_control] if [:cache_control] headers['x-ms-blob-content-type'] = [:blob_content_type] if [:blob_content_type] headers['x-ms-blob-content-encoding'] = [:blob_content_encoding] if [:blob_content_encoding] headers['x-ms-blob-content-language'] = [:blob_content_language] if [:blob_content_language] headers['x-ms-blob-content-md5'] = [:blob_content_md5] if [:blob_content_md5] headers['x-ms-blob-cache-control'] = [:blob_cache_control] if [:blob_cache_control] headers['x-ms-blob-content-disposition'] = [:blob_content_disposition] if [:blob_content_disposition] ([:metadata], headers) if [:metadata] # call PutBlob with empty body response = call(:put, uri, content, headers) result = Serialization.blob_from_headers(response.headers) result.name = blob result end |
#create_container(name, options = {}) ⇒ Object
Public: Create a new container
Attributes
-
name
- String. The name of the container -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:metadata
- Hash. User defined metadata for the container (optional) -
:public_access_level
- String. One of “container” or “blob” (optional) -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179468.aspx
Returns a Container
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/azure/blob/blob_service.rb', line 107 def create_container(name, ={}) query = { } query['timeout'] = [:timeout].to_s if [:timeout] uri = container_uri(name, query) headers = service_properties_headers ([:metadata], headers) if [:metadata] headers['x-ms-blob-public-access'] = [:public_access_level].to_s if [:public_access_level] response = call(:put, uri, nil, headers) container = Serialization.container_from_headers(response.headers) container.name = name container. = [:metadata] container end |
#create_page_blob(container, blob, length, options = {}) ⇒ Object
Public: Creates a new page blob. Note that calling create_page_blob to create a page blob only initializes the blob. To add content to a page blob, call create_blob_pages method.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
length
- Integer. Specifies the maximum size for the page blob, up to 1 TB. The page blob size must be aligned to a 512-byte boundary. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:content_type
- String. Content type for the request. Will be saved with blob unless alternate value is provided in blob_content_type. -
:content_encoding
- String. Content encoding for the request. Will be saved with blob unless alternate value is provided in blob_content_encoding. -
:content_language
- String. Content language for the request. Will be saved with blob unless alternate value is provided in blob_content_language. -
:content_md5
- String. Content MD5 for the request. Will be saved with blob unless alternate value is provided in blob_content_md5. -
:cache_control
- String. Cache control for the request. Will be saved with blob unless alternate value is provided in blob_cache_control. -
:blob_content_type
- String. Content type for the blob. Will be saved with blob. -
:blob_content_encoding
- String. Content encoding for the blob. Will be saved with blob. -
:blob_content_language
- String. Content language for the blob. Will be saved with blob. -
:blob_content_md5
- String. Content MD5 for the blob. Will be saved with blob. -
:blob_cache_control
- String. Cache control for the blob. Will be saved with blob. -
:metadata
- Hash. Custom metadata values to store with the blob. -
:sequence_number
- Integer. The sequence number is a user-controlled value that you can use to track requests. The value of the sequence number must be between 0 and 2^63 - 1.The default value is 0. -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179451.aspx
Returns a Blob
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'lib/azure/blob/blob_service.rb', line 411 def create_page_blob(container, blob, length, ={}) query = { } query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers # set x-ms-blob-type to PageBlob headers['x-ms-blob-type'] = 'PageBlob' # ensure content-length is 0 and x-ms-blob-content-length is the blob length headers['Content-Length'] = 0.to_s headers['x-ms-blob-content-length'] = length.to_s # set x-ms-sequence-number from options (or default to 0) headers['x-ms-sequence-number'] = ([:sequence_number] || 0).to_s # set the rest of the optional headers headers['Content-Type'] = [:content_type] if [:content_type] headers['Content-Encoding'] = [:content_encoding] if [:content_encoding] headers['Content-Language'] = [:content_language] if [:content_language] headers['Content-MD5'] = [:content_md5] if [:content_md5] headers['Cache-Control'] = [:cache_control] if [:cache_control] headers['x-ms-blob-content-type'] = [:blob_content_type] if [:blob_content_type] headers['x-ms-blob-content-encoding'] = [:blob_content_encoding] if [:blob_content_encoding] headers['x-ms-blob-content-language'] = [:blob_content_language] if [:blob_content_language] headers['x-ms-blob-content-md5'] = [:blob_content_md5] if [:blob_content_md5] headers['x-ms-blob-cache-control'] = [:blob_cache_control] if [:blob_cache_control] ([:metadata], headers) if [:metadata] # call PutBlob with empty body response = call(:put, uri, nil, headers) result = Serialization.blob_from_headers(response.headers) result.name = blob result end |
#delete_blob(container, blob, options = {}) ⇒ Object
Public: Deletes a blob or blob snapshot.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:snapshot
- String. An opaque DateTime value that specifies the blob snapshot to retrieve information from. (optional) -
:delete_snapshots
- Symbol. Used to specify the scope of the delete operation for snapshots. This parameter is ignored if a blob does not have snapshots, or if a snapshot is specified in the snapshot parameter. (optional)Possible values include:
-
:only
- Deletes only the snapshots for the blob, but leaves the blob -
:include
- Deletes the blob and all of the snapshots for the blob
-
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179440.aspx
Returns nil on success
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
# File 'lib/azure/blob/blob_service.rb', line 1068 def delete_blob(container, blob, ={}) query = { } query['snapshot'] = [:snapshot] if [:snapshot] query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) [:delete_snapshots] = :include unless [:delete_snapshots] headers = service_properties_headers headers['x-ms-delete-snapshots'] = [:delete_snapshots].to_s if [:delete_snapshots] && [:snapshot] == nil call(:delete, uri, nil, headers) nil end |
#delete_container(name, options = {}) ⇒ Object
Public: Deletes a container
Attributes
-
name
- String. The name of the container -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179408.aspx
Returns nil on success
142 143 144 145 146 147 148 |
# File 'lib/azure/blob/blob_service.rb', line 142 def delete_container(name, ={}) query = { } query['timeout'] = [:timeout].to_s if [:timeout] call(:delete, container_uri(name, query)) nil end |
#get_blob(container, blob, options = {}) ⇒ Object
Public: Reads or downloads a blob from the system, including its metadata and properties.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:start_range
- Integer. Position of first byte of first page. (optional) -
:end_range
- Integer. Position of last byte of of last page. (optional) -
:snapshot
- String. An opaque DateTime value that specifies the blob snapshot to retrieve information from. (optional) -
:get_content_md5
- Boolean. Return the MD5 hash for the range. This option only valid if start_range and end_range are specified. (optional) -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179440.aspx
Returns a blob and the blob body
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
# File 'lib/azure/blob/blob_service.rb', line 1024 def get_blob(container, blob, ={}) query = { } query['snapshot'] = [:snapshot] if [:snapshot] query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers [:start_range] = 0 if [:end_range] and not [:start_range] if [:start_range] headers['x-ms-range'] = "bytes=#{[:start_range]}-#{[:end_range]}" headers['x-ms-range-get-content-md5'] = true if [:get_content_md5] end response = call(:get, uri, nil, headers) result = Serialization.blob_from_headers(response.headers) result.name = blob unless result.name return result, response.body end |
#get_blob_metadata(container, blob, options = {}) ⇒ Object
Public: Returns metadata on the blob.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:snapshot
- String. An opaque DateTime value that specifies the blob snapshot to retrieve information from. -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179350.aspx
Returns a Blob
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 |
# File 'lib/azure/blob/blob_service.rb', line 813 def (container, blob, ={}) query = {'comp' => 'metadata'} query['snapshot'] = [:snapshot] if [:snapshot] query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) response = call(:get, uri) result = Serialization.blob_from_headers(response.headers) result.name = blob result.snapshot = [:snapshot] result end |
#get_blob_properties(container, blob, options = {}) ⇒ Object
Public: Returns all properties and metadata on the blob.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:snapshot
- String. An opaque DateTime value that specifies the blob snapshot to retrieve information from. -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179394.aspx
Returns a Blob
778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 |
# File 'lib/azure/blob/blob_service.rb', line 778 def get_blob_properties(container, blob, ={}) query = { } query['snapshot'] = [:snapshot] if [:snapshot] query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) response = call(:head, uri) result = Serialization.blob_from_headers(response.headers) result.name = blob result.snapshot = [:snapshot] result end |
#get_container_acl(name, options = {}) ⇒ Object
Public: Gets the access control list (ACL) and any container-level access policies for the container.
Attributes
-
name
- String. The name of the container -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179469.aspx
Returns a tuple of (container, signed_identifiers)
container - A Azure::Entity::Blob::Container instance
signed_identifiers - A list of Azure::Entity::SignedIdentifier instances
221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/azure/blob/blob_service.rb', line 221 def get_container_acl(name, ={}) query = { 'comp' => 'acl'} query['timeout'] = [:timeout].to_s if [:timeout] response = call(:get, container_uri(name, query)) container = Serialization.container_from_headers(response.headers) container.name = name signed_identifiers = nil signed_identifiers = Serialization.signed_identifiers_from_xml(response.body) if response.body != nil && response.body.length > 0 return container, signed_identifiers end |
#get_container_metadata(name, options = {}) ⇒ Object
Public: Returns only user-defined metadata for the specified container.
Attributes
-
name
- String. The name of the container -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/ee691976.aspx
Returns a Container
191 192 193 194 195 196 197 198 199 200 |
# File 'lib/azure/blob/blob_service.rb', line 191 def (name, ={}) query = { 'comp' => 'metadata'} query['timeout'] = [:timeout].to_s if [:timeout] response = call(:get, container_uri(name, query)) container = Serialization.container_from_headers(response.headers) container.name = name container end |
#get_container_properties(name, options = {}) ⇒ Object
Public: Returns all properties and metadata on the container.
Attributes
-
name
- String. The name of the container -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179370.aspx
Returns a Container
165 166 167 168 169 170 171 172 173 174 |
# File 'lib/azure/blob/blob_service.rb', line 165 def get_container_properties(name, ={}) query = { } query['timeout'] = [:timeout].to_s if [:timeout] response = call(:get, container_uri(name, query)) container = Serialization.container_from_headers(response.headers) container.name = name container end |
#list_blob_blocks(container, blob, options = {}) ⇒ Object
Public: Retrieves the list of blocks that have been uploaded as part of a block blob.
There are two block lists maintained for a blob: 1) Committed Block List: The list of blocks that have been successfully
committed to a given blob with commitBlobBlocks.
2) Uncommitted Block List: The list of blocks that have been uploaded for a
blob using Put Block (REST API), but that have not yet been committed.
These blocks are stored in Microsoft Azure in association with a blob, but do
not yet form part of the blob.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:blocklist_type
- Symbol. One of :all, :committed, :uncommitted. Defaults to :all (optional) -
:snapshot
- String. An opaque DateTime value that specifies the blob snapshot to retrieve information from. (optional) -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179400.aspx
Returns a list of Azure::Entity::Blob::Block instances
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 |
# File 'lib/azure/blob/blob_service.rb', line 744 def list_blob_blocks(container, blob, ={}) [:blocklist_type] = [:blocklist_type] || :all query = { 'comp' => 'blocklist'} query['snapshot'] = [:snapshot] if [:snapshot] query['blocklisttype'] = [:blocklist_type].to_s if [:blocklist_type] query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) response = call(:get, uri) Serialization.block_list_from_xml(response.body) end |
#list_blobs(name, options = {}) ⇒ Object
Public: Get a list of Blobs from the server
Attributes
-
name
- String. The name of the container to list blobs for. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:prefix
- String. Filters the results to return only blobs whose name begins with the specified prefix. (optional) -
:delimiter
- String. When the request includes this parameter, the operation returns a BlobPrefix element in the response body that acts as a placeholder for all blobs whose names begin with the same substring up to the appearance of the delimiter character. The delimiter may be a single character or a string. -
:marker
- String. An identifier that specifies the portion of the list to be returned. This value comes from the property Azure::Service::EnumerationResults.continuation_token when there are more blobs available than were returned. The marker value may then be used here to request the next set of list items. (optional) -
:max_results
- Integer. Specifies the maximum number of blobs to return. If max_results is not specified, or is a value greater than 5,000, the server will return up to 5,000 items. If it is set to a value less than or equal to zero, the server will return status code 400 (Bad Request). (optional) -
:metadata
- Boolean. Specifies whether or not to return the blob metadata. (optional, Default=false) -
:snapshots
- Boolean. Specifies that snapshots should be included in the enumeration. Snapshots are listed from oldest to newest in the response. (optional, Default=false) -
:uncomittedblobs
- Boolean. Specifies that blobs for which blocks have been uploaded, but which have not been committed using put_block_list, be included in the response. (optional, Default=false) -
:copy
- Boolean. Specifies that metadata related to any current or previous copy_blob operation should be included in the response. (optional, Default=false) -
:timeout
- Integer. A timeout in seconds.
NOTE: Metadata requested with the :metadata parameter must have been stored in accordance with the naming restrictions imposed by the 2009-09-19 version of the Blob service. Beginning with that version, all metadata names must adhere to the naming conventions for C# identifiers.
See: msdn.microsoft.com/en-us/library/azure/dd135734.aspx
Any metadata with invalid names which were previously stored, will be returned with the key “x-ms-invalid-name” in the metadata hash. This may contain multiple values and be an Array (vs a String if it only contains a single value).
Returns an Azure::Service::EnumerationResults
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/azure/blob/blob_service.rb', line 359 def list_blobs(name, ={}) query = { 'comp' => 'list'} query['prefix'] = [:prefix].gsub(/\\/, '/') if [:prefix] query['delimiter'] = [:delimiter] if [:delimiter] query['marker'] = [:marker] if [:marker] query['maxresults'] = [:max_results].to_s if [:max_results] query['timeout'] = [:timeout].to_s if [:timeout] included_datasets = [] included_datasets.push('metadata') if [:metadata] == true included_datasets.push('snapshots') if [:snapshots] == true included_datasets.push('uncommittedblobs') if [:uncommittedblobs] == true included_datasets.push('copy') if [:copy] == true query['include'] = included_datasets.join ',' if included_datasets.length > 0 uri = container_uri(name, query) response = call(:get, uri) Serialization.blob_enumeration_results_from_xml(response.body) end |
#list_containers(options = {}) ⇒ Object
Public: Get a list of Containers from the server
Attributes
-
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:prefix
- String. Filters the results to return only containers whose name begins with the specified prefix. (optional) -
:marker
- String. An identifier the specifies the portion of the list to be returned. This value comes from the property Azure::Service::EnumerationResults.continuation_token when there are more containers available than were returned. The marker value may then be used here to request the next set of list items. (optional) -
:max_results
- Integer. Specifies the maximum number of containers to return. If max_results is not specified, or is a value greater than 5,000, the server will return up to 5,000 items. If it is set to a value less than or equal to zero, the server will return status code 400 (Bad Request). (optional) -
:metadata
- Boolean. Specifies whether or not to return the container metadata. (optional, Default=false) -
:timeout
- Integer. A timeout in seconds.
NOTE: Metadata requested with the :metadata parameter must have been stored in accordance with the naming restrictions imposed by the 2009-09-19 version of the Blob service. Beginning with that version, all metadata names must adhere to the naming conventions for C# identifiers.
See: msdn.microsoft.com/en-us/library/aa664670(VS.71).aspx
Any metadata with invalid names which were previously stored, will be returned with the key “x-ms-invalid-name” in the metadata hash. This may contain multiple values and be an Array (vs a String if it only contains a single value).
Returns an Azure::Service::EnumerationResults
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/azure/blob/blob_service.rb', line 74 def list_containers(={}) query = { } if query['prefix'] = [:prefix] if [:prefix] query['marker'] = [:marker] if [:marker] query['maxresults'] = [:max_results].to_s if [:max_results] query['include'] = 'metadata' if [:metadata] == true query['timeout'] = [:timeout].to_s if [:timeout] end uri = containers_uri(query) response = call(:get, uri) Serialization.container_enumeration_results_from_xml(response.body) end |
#list_page_blob_ranges(container, blob, options = {}) ⇒ Object
Public: Returns a list of active page ranges for a page blob. Active page ranges are those that have been populated with data.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:start_range
- Integer. Position of first byte of first page. (optional) -
:end_range
- Integer. Position of last byte of of last page. (optional) -
:snapshot
- String. An opaque DateTime value that specifies the blob snapshot to retrieve information from. (optional) -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/ee691973.aspx
Returns a list of page ranges in the format [ [start, end], [start, end], … ]
eg. [ [0, 511], [512, 1024], ... ]
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 |
# File 'lib/azure/blob/blob_service.rb', line 854 def list_page_blob_ranges(container, blob, ={}) query = {'comp' => 'pagelist'} query.update({'snapshot' => [:snapshot]}) if [:snapshot] query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) [:start_range] = 0 if [:end_range] and not [:start_range] headers = service_properties_headers headers = { 'x-ms-range' => "bytes=#{[:start_range]}-#{[:end_range]}" } if [:start_range] response = call(:get, uri, nil, headers) pagelist = Serialization.page_list_from_xml(response.body) pagelist end |
#release_lease(container, blob, lease, options = {}) ⇒ Object
Public: Releases the lease. The lease may be released if the lease ID specified on the request matches that associated with the blob. Releasing the lease allows another client to immediately acquire the lease for the blob as soon as the release is complete.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
lease
- String. The lease id. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/ee691972.aspx
Returns nil on success
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 |
# File 'lib/azure/blob/blob_service.rb', line 1308 def release_lease(container, blob, lease, ={}) query = { 'comp' => 'lease'} query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers headers['x-ms-lease-action'] = 'release' headers['x-ms-lease-id'] = lease call(:put, uri, nil, headers) nil end |
#renew_lease(container, blob, lease, options = {}) ⇒ Object
Public: Renews the lease. The lease can be renewed if the lease ID specified on the request matches that associated with the blob. Note that the lease may be renewed even if it has expired as long as the blob has not been modified or leased again since the expiration of that lease. When you renew a lease, the lease duration clock resets.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
lease
- String. The lease id -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/ee691972.aspx
Returns the renewed lease id
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 |
# File 'lib/azure/blob/blob_service.rb', line 1275 def renew_lease(container, blob, lease, ={}) query = { 'comp' => 'lease'} query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers headers['x-ms-lease-action'] = 'renew' headers['x-ms-lease-id'] = lease response = call(:put, uri, nil, headers) response.headers['x-ms-lease-id'] end |
#set_blob_metadata(container, blob, metadata, options = {}) ⇒ Object
Public: Sets metadata headers on the blob.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
metadata
- Hash. The custom metadata. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179414.aspx
Returns nil on success.
989 990 991 992 993 994 995 996 997 998 999 1000 |
# File 'lib/azure/blob/blob_service.rb', line 989 def (container, blob, , ={}) query = { 'comp' => 'metadata'} query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers (, headers) if call(:put, uri, nil, headers) nil end |
#set_blob_properties(container, blob, options = {}) ⇒ Object
Public: Sets system properties defined for a blob.
Attributes
-
container
- String. The container name. -
blob
- String. The blob name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:content_type
- String. Content type for the blob. Will be saved with blob. -
:content_encoding
- String. Content encoding for the blob. Will be saved with blob. -
:content_language
- String. Content language for the blob. Will be saved with blob. -
:content_md5
- String. Content MD5 for the blob. Will be saved with blob. -
:cache_control
- String. Cache control for the blob. Will be saved with blob. -
:content_length
- Integer. Resizes a page blob to the specified size. If the specified value is less than the current size of the blob, then all pages above the specified value are cleared. This property cannot be used to change the size of a block blob. Setting this property for a block blob returns status code 400 (Bad Request). -
:sequence_number_action
- Symbol. This property indicates how the service should modify the sequence number for the blob. Required if :sequence_number is used. This property applies to page blobs only.Specify one of the following options for this property:
-
:max
- Sets the sequence number to be the higher of the value included with the request and the value currently stored for the blob. -
:update
- Sets the sequence number to the value included with the request. -
:increment
- Increments the value of the sequence number by 1. If specifying this option, do not include the sequence_number option; doing so will return status code 400 (Bad Request).
-
-
:sequence_number
- Integer. This property sets the blob’s sequence number. The sequence number is a user-controlled property that you can use to track requests and manage concurrency issues. Required if the :sequence_number_action option is set to :max or :update. This property applies to page blobs only.Use this together with the :sequence_number_action to update the blob’s sequence number, either to the specified value or to the higher of the values specified with the request or currently stored with the blob.
This header should not be specified if :sequence_number_action is set to :increment; in this case the service automatically increments the sequence number by one.
To set the sequence number to a value of your choosing, this property must be specified together with :sequence_number_action
-
:timeout
- Integer. A timeout in seconds.
Remarks:
The semantics for updating a blob’s properties are as follows:
-
A page blob’s sequence number is updated only if the request meets either of the following conditions:
* The :sequence_number_action property is set to :max or :update, and a value for :sequence_number is also set. * The :sequence_number_action property is set to :increment, indicating that the service should increment the sequence number by one.
-
The size of the page blob is modified only if a value for :content_length is specified.
-
If :sequence_number and/or :content_length are the only properties specified, then the other properties of the blob will NOT be modified.
-
If any one or more of the following properties are set, then all of these properties are set together. If a value is not provided for a given property when at least one of the properties listed below is set, then that property will be cleared for the blob.
* :cache_control * :content_type * :content_md5 * :content_encoding * :content_language
See msdn.microsoft.com/en-us/library/azure/ee691966.aspx
Returns nil on success.
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 |
# File 'lib/azure/blob/blob_service.rb', line 949 def set_blob_properties(container, blob, ={}) query = { 'comp' => 'properties'} query['timeout'] = [:timeout].to_s if [:timeout] uri = blob_uri(container, blob, query) headers = service_properties_headers unless .empty? headers['x-ms-blob-content-type'] = [:blob_content_type] if [:blob_content_type] headers['x-ms-blob-content-encoding'] = [:blob_content_encoding] if [:blob_content_encoding] headers['x-ms-blob-content-language'] = [:blob_content_language] if [:blob_content_language] headers['x-ms-blob-content-md5'] = [:blob_content_md5] if [:blob_content_md5] headers['x-ms-blob-cache-control'] = [:blob_cache_control] if [:blob_cache_control] headers['x-ms-blob-content-length'] = [:blob_content_length].to_s if [:blob_content_length] headers['x-ms-blob-sequence-number-action'] = [:sequence_number_action].to_s if [:sequence_number_action] headers['x-ms-blob-sequence-number'] = [:sequence_number].to_s if [:sequence_number] headers['x-ms-blob-content-disposition'] = [:blob_content_disposition] if [:blob_content_disposition] end call(:put, uri, nil, headers) nil end |
#set_container_acl(name, public_access_level, options = {}) ⇒ Object
Public: Sets the ACL and any container-level access policies for the container.
Attributes
-
name
- String. The name of the container -
public_access_level
- String. The container public access level -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:signed_identifiers
- Array. A list of Azure::Entity::SignedIdentifier instances (optional) -
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179391.aspx
Returns a tuple of (container, signed_identifiers)
-
container
- A Azure::Entity::Blob::Container instance -
signed_identifiers
- A list of Azure::Entity::SignedIdentifier instances
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/azure/blob/blob_service.rb', line 255 def set_container_acl(name, public_access_level, ={}) query = { 'comp' => 'acl'} query['timeout'] = [:timeout].to_s if [:timeout] uri =container_uri(name, query) headers = service_properties_headers headers['x-ms-blob-public-access'] = public_access_level if public_access_level && public_access_level.to_s.length > 0 signed_identifiers = nil signed_identifiers = [:signed_identifiers] if [:signed_identifiers] body = nil body = Serialization.signed_identifiers_to_xml(signed_identifiers) if signed_identifiers response = call(:put, uri, body, headers) container = Serialization.container_from_headers(response.headers) container.name = name container.public_access_level = public_access_level return container, signed_identifiers || [] end |
#set_container_metadata(name, metadata, options = {}) ⇒ Object
Public: Sets custom metadata for the container.
Attributes
-
name
- String. The name of the container -
metadata
- Hash. A Hash of the metadata values -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179362.aspx
Returns nil on success
295 296 297 298 299 300 301 302 303 304 |
# File 'lib/azure/blob/blob_service.rb', line 295 def (name, , ={}) query = { 'comp' => 'metadata'} query['timeout'] = [:timeout].to_s if [:timeout] headers = service_properties_headers (, headers) if call(:put, container_uri(name, query), nil, headers) nil end |