Module: BucketClient::BlobMethods
- Included in:
- Client
- Defined in:
- lib/bucket_client/client.rb
Instance Method Summary collapse
-
#delete_blob(uri) ⇒ OperationResult
Deletes the blob in the provided URI Fails if the blob does not exist.
-
#delete_blob!(uri) ⇒ Object
Deletes the blob in the provided URI Fails if the blob does not exist.
-
#delete_blob_if_exist(uri) ⇒ OperationResult
Deletes the blob if it exist, else does nothing.
-
#delete_blob_if_exist!(uri) ⇒ Object
Deletes the blob if it exist, else does nothing.
-
#exist_blob(uri) ⇒ Boolean
Check if blob with URI exist#.
-
#get_blob(uri) ⇒ OperationResult
Gets the blob in the target URL as byte array.
-
#get_blob!(uri) ⇒ Array<Byte>
Gets the blob in the target URL as byte array.
-
#put_blob(payload, uri) ⇒ OperationResult
Creates the blob with the payload if it does not exist, Updates the blob with the new payload if it exist.
-
#put_blob!(payload, uri) ⇒ String
Creates the blob with the payload if it does not exist, Updates the blob with the new payload if it exist.
-
#update_blob(payload, uri) ⇒ OperationResult
Updates a blob with new payload in byte array Fails if blob with the URI doesn’t exist.
-
#update_blob!(payload, uri) ⇒ Object
Updates a blob with new payload in byte array Fails if blob doesnt exist.
Instance Method Details
#delete_blob(uri) ⇒ OperationResult
Deletes the blob in the provided URI Fails if the blob does not exist. Use delete_blob_if_exist if you do not want this behaviour
uri = “
” result = client.delete_blob uri result.success #=> Whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> nil
355 356 357 |
# File 'lib/bucket_client/client.rb', line 355 def delete_blob(uri) raise NotImplementedError uri end |
#delete_blob!(uri) ⇒ Object
Deletes the blob in the provided URI Fails if the blob does not exist. Use delete_blob_if_exist if you do not want this behaviour
Raises exception if the operation fails
uri = “
” client.delete_blob! uri
369 370 371 372 |
# File 'lib/bucket_client/client.rb', line 369 def delete_blob!(uri) result = delete_blob uri raise BucketOperationException.new(result) unless result.success end |
#delete_blob_if_exist(uri) ⇒ OperationResult
Deletes the blob if it exist, else does nothing
uri = “
” result = client.delete_blob uri result.success #=> Whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> nil
385 386 387 |
# File 'lib/bucket_client/client.rb', line 385 def delete_blob_if_exist(uri) raise NotImplementedError uri end |
#delete_blob_if_exist!(uri) ⇒ Object
Deletes the blob if it exist, else does nothing
Raises exception if the operation fails
uri = “
” client.delete_blob! uri
397 398 399 400 |
# File 'lib/bucket_client/client.rb', line 397 def delete_blob_if_exist!(uri) result = delete_blob_if_exist uri raise BucketOperationException.new(result) unless result.success end |
#exist_blob(uri) ⇒ Boolean
Check if blob with URI exist#
Raises exception when the operation fails
exist = exist_blob “host.com/folder/blob.ext” exist #=> true if exist, false if does not exist
267 268 269 |
# File 'lib/bucket_client/client.rb', line 267 def exist_blob(uri) raise NotImplementedError uri end |
#get_blob(uri) ⇒ OperationResult
Gets the blob in the target URL as byte array.
blob = client.get_blob “host.com/bucket” result.success #=> Whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> Byte array (payload of blob)
240 241 242 |
# File 'lib/bucket_client/client.rb', line 240 def get_blob(uri) raise NotImplementedError uri end |
#get_blob!(uri) ⇒ Array<Byte>
Gets the blob in the target URL as byte array
Raises exception if operation fails
blob = client.get_blob! “host.com/bucket” #=> [12,65,127,33] (some byte array)
252 253 254 255 256 |
# File 'lib/bucket_client/client.rb', line 252 def get_blob!(uri) result = get_blob(uri) raise BucketOperationException.new(result) unless result.success result.value end |
#put_blob(payload, uri) ⇒ OperationResult
Creates the blob with the payload if it does not exist, Updates the blob with the new payload if it exist
img = IO.binread “pic.png” uri = “
” result = client.put_blob img, uri result.success #=> Whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> Uri of blob
320 321 322 |
# File 'lib/bucket_client/client.rb', line 320 def put_blob(payload, uri) raise NotImplementedError payload.to_s + uri end |
#put_blob!(payload, uri) ⇒ String
Creates the blob with the payload if it does not exist, Updates the blob with the new payload if it exist
Raises exception if the operation fails
img = IO.binread “pic.png” uri = “
” result = client.put_blob!(img,uri) #=> returns URI of updated blob
336 337 338 339 340 |
# File 'lib/bucket_client/client.rb', line 336 def put_blob!(payload, uri) result = put_blob payload, uri raise NotImplementedError result unless result.success result.value end |
#update_blob(payload, uri) ⇒ OperationResult
Updates a blob with new payload in byte array Fails if blob with the URI doesn’t exist
img = IO.binread “pic.png” uri = “
” result = client.update_blob img, uri result.success #=> Whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> Uri of update blob
285 286 287 |
# File 'lib/bucket_client/client.rb', line 285 def update_blob(payload, uri) raise NotImplementedError payload.to_s + uri end |
#update_blob!(payload, uri) ⇒ Object
Updates a blob with new payload in byte array Fails if blob doesnt exist
Raises exception if operation fails
img = IO.binread “pic.png” uri = “
” result = client.update_blob! img, uri #=> URI of update blob
300 301 302 303 304 |
# File 'lib/bucket_client/client.rb', line 300 def update_blob!(payload, uri) result = update_blob payload, uri raise BucketOperationException.new(result) unless result.success result.value end |