@@ -142,7 +142,8 @@ def list_blobs(options = {})
142142 #
143143 # Calls to {Get Blob Properties}[https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-properties]
144144 #
145- # This can be used to see if the blob exist or obtain metadata such as content type, disposition, checksum or Azure custom metadata.
145+ # This can be used to obtain metadata such as content type, disposition, checksum or Azure custom metadata.
146+ # To check for blob presence, look for `blob_exist?` as `get_blob_properties` raises on missing blob.
146147 def get_blob_properties ( key , options = { } )
147148 uri = generate_uri ( "#{ container } /#{ key } " )
148149
@@ -151,6 +152,15 @@ def get_blob_properties(key, options = {})
151152 Blob . new ( response )
152153 end
153154
155+ # Returns a boolean indicating if the blob exists.
156+ #
157+ # Calls to {Get Blob Properties}[https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-properties]
158+ def blob_exist? ( key , options = { } )
159+ get_blob_properties ( key , options ) . present?
160+ rescue AzureBlob ::Http ::FileNotFoundError
161+ false
162+ end
163+
154164 # Returns the tags associated with a blob
155165 #
156166 # Calls to the {Get Blob Tags}[https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-tags] endpoint.
@@ -178,6 +188,13 @@ def get_container_properties(options = {})
178188 Container . new ( response )
179189 end
180190
191+ # Returns a boolean indicating if the container exists.
192+ #
193+ # Calls to {Get Container Properties}[https://learn.microsoft.com/en-us/rest/api/storageservices/get-container-properties]
194+ def container_exist? ( options = { } )
195+ get_container_properties ( options = { } ) . present?
196+ end
197+
181198 # Create the container
182199 #
183200 # Calls to {Create Container}[https://learn.microsoft.com/en-us/rest/api/storageservices/create-container]
0 commit comments