Class: AzureBlob::Blob
- Inherits:
-
Object
- Object
- AzureBlob::Blob
- Defined in:
- lib/azure_blob/blob.rb
Overview
AzureBlob::Blob holds the metadata for a given Blob.
Instance Method Summary collapse
- #checksum ⇒ Object
- #content_disposition ⇒ Object
- #content_type ⇒ Object
-
#initialize(response) ⇒ Blob
constructor
You should not instanciate this object directly, but obtain one when calling relevant methods of AzureBlob::Client.
-
#metadata ⇒ Object
Returns the custom Azure metadata tagged on the blob.
- #present? ⇒ Boolean
- #size ⇒ Object
Constructor Details
#initialize(response) ⇒ Blob
You should not instanciate this object directly, but obtain one when calling relevant methods of AzureBlob::Client.
Expects a Net::HTTPResponse object from a HEAD or GET request to a blob uri.
11 12 13 |
# File 'lib/azure_blob/blob.rb', line 11 def initialize(response) @response = response end |
Instance Method Details
#checksum ⇒ Object
23 24 25 |
# File 'lib/azure_blob/blob.rb', line 23 def checksum response["content-md5"] end |
#content_disposition ⇒ Object
19 20 21 |
# File 'lib/azure_blob/blob.rb', line 19 def content_disposition response["content-disposition"] end |
#content_type ⇒ Object
15 16 17 |
# File 'lib/azure_blob/blob.rb', line 15 def content_type response.content_type end |
#metadata ⇒ Object
Returns the custom Azure metadata tagged on the blob.
36 37 38 39 40 41 42 |
# File 'lib/azure_blob/blob.rb', line 36 def @metadata || response .to_hash .select { |key, _| key.start_with?("x-ms-meta") } .transform_values(&:first) .transform_keys { |key| key.delete_prefix("x-ms-meta-").to_sym } end |
#present? ⇒ Boolean
31 32 33 |
# File 'lib/azure_blob/blob.rb', line 31 def present? response.code == "200" end |
#size ⇒ Object
27 28 29 |
# File 'lib/azure_blob/blob.rb', line 27 def size response.content_length end |