Module: BucketClient::UriMethod
- Included in:
- Bucket
- Defined in:
- lib/bucket_client/bucket.rb
Instance Method Summary collapse
-
#delete_blob_if_exist_with_uri(uri) ⇒ OperationResult
Deletes the blob if it exist, else does nothing.
-
#delete_blob_if_exist_with_uri!(uri) ⇒ Object
Deletes the blob if it exist, else does nothing Raises exception if the operation fails.
-
#delete_blob_with_uri(uri) ⇒ OperationResult
Deletes the blob in the provided URI Fails if the blob does not exist.
-
#delete_blob_with_uri!(uri) ⇒ Object
Deletes the blob in the provided URI Fails if the blob does not exist.
-
#exist_blob_with_uri(uri) ⇒ Boolean
Check if blob exist.
-
#get_blob_with_uri(uri) ⇒ OperationResult
Gets the blob in the target URL as byte array.
-
#get_blob_with_uri!(uri) ⇒ Array<Byte>
Gets the blob in the target URL as byte array.
-
#put_blob_with_uri(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_with_uri!(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_with_uri(payload, uri) ⇒ OperationResult
Updates a blob with new payload in byte array Fails if blob with the URI doesn’t exist.
-
#update_blob_with_uri!(payload, uri) ⇒ Object
Updates a blob with new payload in byte array Fails if blob with the URI doesn’t exist Raises exception when fails.
Instance Method Details
#delete_blob_if_exist_with_uri(uri) ⇒ OperationResult
Deletes the blob if it exist, else does nothing
uri = “
” result = bucket.delete_blob_with_uri uri result.success #=> whether the operation succeeded result.code #=> Status code of the operation result.message #=> Error message if the operation failed result.value #=> nil
356 357 358 |
# File 'lib/bucket_client/bucket.rb', line 356 def delete_blob_if_exist_with_uri(uri) raise NotImplementedError uri end |
#delete_blob_if_exist_with_uri!(uri) ⇒ Object
Deletes the blob if it exist, else does nothing Raises exception if the operation fails
uri = “
” bucket.delete_blob_with_uri! uri
367 368 369 370 |
# File 'lib/bucket_client/bucket.rb', line 367 def delete_blob_if_exist_with_uri!(uri) result = delete_blob_if_exist_with_uri uri raise BucketOperationException.new(result) unless result.success end |
#delete_blob_with_uri(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 = bucket.delete_blob_with_uri uri result.success #=> whether the operation succeeded result.code #=> Status code of the operation result.message #=> Error message if the operation failed result.value #=> nil
326 327 328 |
# File 'lib/bucket_client/bucket.rb', line 326 def delete_blob_with_uri(uri) raise NotImplementedError uri end |
#delete_blob_with_uri!(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 = “
” bucket.delete_blob_with_uri! uri
340 341 342 343 |
# File 'lib/bucket_client/bucket.rb', line 340 def delete_blob_with_uri!(uri) result = delete_blob_with_uri uri raise BucketOperationException.new(result) unless result.success end |
#exist_blob_with_uri(uri) ⇒ Boolean
Check if blob exist
Raises exception if the operation fails
exist = bucket.exist_blob_with_uri “host.com/folder/blob.ext” exist #=> true if exist, false if does not exist
239 240 241 |
# File 'lib/bucket_client/bucket.rb', line 239 def exist_blob_with_uri(uri) raise NotImplementedError uri end |
#get_blob_with_uri(uri) ⇒ OperationResult
Gets the blob in the target URL as byte array.
blob = bucket.get_blob_with_uri “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 #=> payload of the blob as byte array
212 213 214 |
# File 'lib/bucket_client/bucket.rb', line 212 def get_blob_with_uri(uri) raise NotImplementedError uri end |
#get_blob_with_uri!(uri) ⇒ Array<Byte>
Gets the blob in the target URL as byte array
Raises exception if operation fails
blob = bucket.get_blob_with_uri! “host.com/bucket” #=> [12,65,127,33] (some byte array)
224 225 226 227 228 |
# File 'lib/bucket_client/bucket.rb', line 224 def get_blob_with_uri!(uri) result = get_blob_with_uri(uri) raise BucketOperationException.new(result) unless result.success result.value end |
#put_blob_with_uri(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 = bucket.put_blob_with_uri img, uri result.success #=> whether the operation succeeded result.code #=> Status code of the operation result.message #=> Error message if the operation failed result.value #=> Uri of blob
291 292 293 |
# File 'lib/bucket_client/bucket.rb', line 291 def put_blob_with_uri(payload, uri) raise NotImplementedError payload.to_s + uri end |
#put_blob_with_uri!(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 = bucket.put_blob_with_uri!(img,uri) #=> returns URI of updated blob
307 308 309 310 311 |
# File 'lib/bucket_client/bucket.rb', line 307 def put_blob_with_uri!(payload, uri) result = put_blob_with_uri payload, uri raise BucketOperationException.new(result) unless result.success result.value end |
#update_blob_with_uri(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 = bucket.update_blob_with_uri 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
257 258 259 |
# File 'lib/bucket_client/bucket.rb', line 257 def update_blob_with_uri(payload, uri) raise NotImplementedError payload.to_s + uri end |
#update_blob_with_uri!(payload, uri) ⇒ Object
Updates a blob with new payload in byte array Fails if blob with the URI doesn’t exist Raises exception when fails
img = IO.binread “pic.png” uri = “
” result = bucket.update_blob_with_uri!(img, uri) #=> URI of update blob
271 272 273 274 275 |
# File 'lib/bucket_client/bucket.rb', line 271 def update_blob_with_uri!(payload, uri) result = update_blob_with_uri payload, uri raise BucketOperationException.new(result) unless result.success result.value end |