Class: AzureBlob::Blob

Inherits:
Object
  • Object
show all
Defined in:
lib/azure_blob/blob.rb

Overview

AzureBlob::Blob holds the metadata for a given Blob.

Instance Method Summary collapse

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

#checksumObject



23
24
25
# File 'lib/azure_blob/blob.rb', line 23

def checksum
  response["content-md5"]
end

#content_dispositionObject



19
20
21
# File 'lib/azure_blob/blob.rb', line 19

def content_disposition
  response["content-disposition"]
end

#content_typeObject



15
16
17
# File 'lib/azure_blob/blob.rb', line 15

def content_type
  response.content_type
end

#metadataObject

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

Returns:

  • (Boolean)


31
32
33
# File 'lib/azure_blob/blob.rb', line 31

def present?
  response.code == "200"
end

#sizeObject



27
28
29
# File 'lib/azure_blob/blob.rb', line 27

def size
  response.content_length
end