Method: Azure::Storage::Blob#get_blob
- Defined in:
- lib/azure/storage/blob/blob.rb
#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 toretrieve information from. (optional)
-
:get_content_md5
- Boolean. Return the MD5 hash for the range. This option only valid ifstart_range and end_range are specified. (optional)
-
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
-
:location_mode
- LocationMode. Specifies the location mode used to decidewhich location the request should be sent to.
-
:if_modified_since
- String. A DateTime value. Specify this conditional header to get the blobonly 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
- String. A DateTime value. Specify this conditional header to get the blobonly 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
- String. An ETag value. Specify an ETag value for this conditional header to get the blobonly 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
- String. An ETag value. Specify an ETag value for this conditional header to get the blobonly 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).
-
:lease_id
- String. If this header is specified, the operation will be performed only if both of thefollowing conditions are met: - The blob's lease is currently active. - The lease ID specified in the request matches that of the blob. If this header is specified and both of these conditions are not met, the request will fail and the Get Blob operation will fail with status code 412 (Precondition Failed).
See msdn.microsoft.com/en-us/library/azure/dd179440.aspx
Returns a blob and the blob body
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/azure/storage/blob/blob.rb', line 89 def get_blob(container, blob, = {}) query = {} StorageService.with_query query, "snapshot", [:snapshot] StorageService.with_query query, "timeout", [:timeout] if [:timeout] [:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY uri = blob_uri(container, blob, query, ) headers = {} [:start_range] = 0 if [:end_range] && (not [:start_range]) if [:start_range] StorageService.with_header headers, "x-ms-range", "bytes=#{[:start_range]}-#{[:end_range]}" StorageService.with_header headers, "x-ms-range-get-content-md5", "true" if [:get_content_md5] end add_blob_conditional_headers , headers headers["x-ms-lease-id"] = [:lease_id] if [:lease_id] response = call(:get, uri, nil, headers, ) result = Serialization.blob_from_headers(response.headers) result.name = blob unless result.name return result, response.body end |