Class: Fog::Storage::AzureRM::Files
- Inherits:
-
Collection
- Object
- Collection
- Fog::Storage::AzureRM::Files
- Defined in:
- lib/fog/azurerm/models/storage/files.rb
Overview
This class is giving implementation of listing blobs.
Instance Method Summary collapse
-
#all(options = {}) ⇒ Fog::Storage::AzureRM::Files
List all files(blobs) under the directory.
- #each ⇒ Object
-
#each_file_this_page ⇒ Fog::Storage::AzureRM::Files
Enumerate every file under the directory if block_given?.
-
#get(key, options = {}, &block) ⇒ Fog::Storage::AzureRM::File
Get the file(blob) with full content as :body with the given name.
-
#get_http_url(key, expires, _options = {}) ⇒ String
Get the http URL of the file(blob) with the given name.
-
#get_https_url(key, expires, _options = {}) ⇒ String
Get the https URL of the file(blob) with the given name.
-
#get_url(key, expires, options = {}) ⇒ String
Get the URL of the file(blob) with the given name.
-
#head(key, options = {}) ⇒ Fog::Storage::AzureRM::File
Get the file(blob) without content with the given name.
-
#new(attributes = {}) ⇒ Fog::Storage::AzureRM::File
Create a new file.
Instance Method Details
#all(options = {}) ⇒ Fog::Storage::AzureRM::Files
List all files(blobs) under the directory.
required attributes: directory
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fog/azurerm/models/storage/files.rb', line 30 def all( = {}) requires :directory = { max_results: max_results, delimiter: delimiter, marker: marker, prefix: prefix }.merge!() = .reject { |_key, value| value.nil? || value.to_s.empty? } merge_attributes() parent = directory.collection.get( directory.key, ) return nil unless parent merge_attributes(parent.files.attributes) load(parent.files.map(&:attributes)) end |
#each ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fog/azurerm/models/storage/files.rb', line 56 def each if block_given? subset = dup.all subset.each_file_this_page { |f| yield f } while subset.next_marker subset = subset.all(marker: subset.next_marker) subset.each_file_this_page { |f| yield f } end end self end |
#each_file_this_page ⇒ Fog::Storage::AzureRM::Files
Enumerate every file under the directory if block_given?
55 |
# File 'lib/fog/azurerm/models/storage/files.rb', line 55 alias each_file_this_page each |
#get(key, options = {}, &block) ⇒ Fog::Storage::AzureRM::File
Get the file(blob) with full content as :body with the given name.
required attributes: directory
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fog/azurerm/models/storage/files.rb', line 80 def get(key, = {}, &block) requires :directory blob, content = service.get_blob(directory.key, key, , &block) data = parse_storage_object(blob) file_data = data.merge( body: content, key: key ) new(file_data) rescue => error return nil if error. == 'NotFound' raise error end |
#get_http_url(key, expires, _options = {}) ⇒ String
Get the http URL of the file(blob) with the given name.
required attributes: directory
126 127 128 129 130 |
# File 'lib/fog/azurerm/models/storage/files.rb', line 126 def get_http_url(key, expires, = {}) requires :directory service.get_blob_http_url(directory.key, key, expires) end |
#get_https_url(key, expires, _options = {}) ⇒ String
Get the https URL of the file(blob) with the given name.
required attributes: directory
142 143 144 145 146 |
# File 'lib/fog/azurerm/models/storage/files.rb', line 142 def get_https_url(key, expires, = {}) requires :directory service.get_blob_https_url(directory.key, key, expires) end |
#get_url(key, expires, options = {}) ⇒ String
Get the URL of the file(blob) with the given name.
required attributes: directory
106 107 108 109 110 111 112 113 114 |
# File 'lib/fog/azurerm/models/storage/files.rb', line 106 def get_url(key, expires, = {}) requires :directory if [:scheme] == 'http' get_http_url(key, expires, ) else get_https_url(key, expires, ) end end |
#head(key, options = {}) ⇒ Fog::Storage::AzureRM::File
Get the file(blob) without content with the given name.
required attributes: directory
157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/fog/azurerm/models/storage/files.rb', line 157 def head(key, = {}) requires :directory blob = service.get_blob_properties(directory.key, key, ) data = parse_storage_object(blob) file_data = data.merge(key: key) new(file_data) rescue => error return nil if error. == 'NotFound' raise error end |
#new(attributes = {}) ⇒ Fog::Storage::AzureRM::File
Create a new file.
required attributes: directory
175 176 177 178 179 |
# File 'lib/fog/azurerm/models/storage/files.rb', line 175 def new(attributes = {}) requires :directory super({ directory: directory }.merge!(attributes)) end |