module BucketClient::KeyMethod

Public Instance Methods

create_blob(payload, key) click to toggle source

Create blob with payload Fails if blob already exist

img = IO.binread “image.png” result = bucket.create_blob img, “image.png” result.success #=> Whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> URI of the blob

@param [Array<Byte>] payload the payload to create blob with @param [String] key the blob id or name @return [OperationResult]

# File lib/bucket_client/bucket.rb, line 58
def create_blob(payload, key)
        raise NotImplementedError payload.to_s, key
end
create_blob!(payload, key) click to toggle source

Creates blob with payload Fails if blob already exist

Raises exception if operation fails

img = IO.binread “image.png” uri = bucket.create_blob! img, “image.png” #=> URI of the created blob

@param [Array<Byte>] payload the payload to create blob with @param [String] key the blob id or name @return [String]

# File lib/bucket_client/bucket.rb, line 73
def create_blob!(payload, key)
        result = create_blob payload, key
        raise BucketOperationException.new(result) unless result.success
        result.value
end
delete_blob(key) click to toggle source

Deletes a blob Fails if the blob does not exist. To prevent this behaviour, use delete_blob_if_exist method

result = bucket.delete_blob “image.png” result.success #=> whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> nil

@param [String] key the blob id or name @return [OperationResult]

# File lib/bucket_client/bucket.rb, line 158
def delete_blob(key)
        raise NotImplementedError key
end
delete_blob!(key) click to toggle source

Deletes a blob Fails if the blob does not exist. To prevent this behaviour, use delete_blob_if_exist method

Raises exception if the operation fails

bucket.delete_blob! “image.png” @param [String] key the blob id or name

# File lib/bucket_client/bucket.rb, line 170
def delete_blob!(key)
        result = delete_blob key
        raise BucketOperationException.new(result) unless result.success
end
delete_blob_if_exist(key) click to toggle source

Deletes a blob if it exist

result = bucket.delete_blob_if_exist “image.png” result.success #=> whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> nil

@param [String] key the blob id or name @return [OperationResult]

# File lib/bucket_client/bucket.rb, line 185
def delete_blob_if_exist(key)
        raise NotImplementedError key
end
delete_blob_if_exist!(key) click to toggle source

Deletes a blob if it exist Raises exception if operation fails

bucket.delete_blob_if_exist! “image.png”

@param [String] key the blob id or name

# File lib/bucket_client/bucket.rb, line 195
def delete_blob_if_exist!(key)
        result = delete_blob_if_exist key
        raise BucketOperationException.new(result) unless result.success
end
exist_blob(key) click to toggle source

Check if the blob exist

Raises exception if operation fails

exist = bucket.exist_blob “image.png” #=> true if exist, false if not

@param [String] key the blob id or name @return [Boolean]

# File lib/bucket_client/bucket.rb, line 41
def exist_blob(key)
        raise NotImplementedError key
end
get_blob(key) click to toggle source

Get blob as byte array

result = bucket.get_blob “image.png” result.success #=> Whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> the byte array of the blob

@param [String] key the blob id or name @return [OperationResult]

# File lib/bucket_client/bucket.rb, line 15
def get_blob(key)
        raise NotImplementedError key
end
get_blob!(key) click to toggle source

Get blob as byte array

Raises exception if the operation fails.

img = bucket.get_blob! “image.png”

@param [String] key the blob id or name @return [Array<Byte>]

# File lib/bucket_client/bucket.rb, line 27
def get_blob!(key)
        result = get_blob key
        raise BucketOperationException.new(result) unless result.success
        result.value
end
put_blob(payload, key) click to toggle source

Creates a new blob with payload if blob does not exist Updates blob with new payload if blob exist

img = IO.binread “image.png” result = bucket.put_blob(img, “image.png”) result.success #=> whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> URI of the blob

@param [Array<Byte>] payload the payload to put @param [String] key the blob id or name @return [OperationResult]

# File lib/bucket_client/bucket.rb, line 125
def put_blob(payload, key)
        raise NotImplementedError payload.to_s, key
end
put_blob!(payload, key) click to toggle source

Creates a new blob with payload if blob does not exist Updates blob with new payload if blob exist

Raises exception if operation fails

img = IO.binread “image.png” uri = bucket.put_blob! img, “image.png” #=> uri of the blob

@param [Array<Byte>] payload the payload to put @param [String] key the blob id or name @return [String]

# File lib/bucket_client/bucket.rb, line 140
def put_blob!(payload, key)
        result = put_blob payload, key
        raise BucketOperationException.new(result) unless result.success
        result.value
end
update_blob(payload, key) click to toggle source

Updates the blob with new payload Fails if blob does not exist

img = IO.binread “image.png” result = bucket.update_blob img, “image.png” result.success #=> whether the operation succeeded result.code #=> Status Code of the operation result.message #=> Error message if it failed result.value #=> URI of the blob

@param [Array<Byte>] payload the payload to update @param [String] key the blob id or name @return [OperationResult]

# File lib/bucket_client/bucket.rb, line 92
def update_blob(payload, key)
        raise NotImplementedError payload.to_s, key
end
update_blob!(payload, key) click to toggle source

Updates the blob with new payload Fails if blob does not exist Raises exception if operation fails

img = IO.binread “image.png” result = bucket.update_blob!(img, “image.png”) #=> URI of updated blob

@param [Array<Byte>] payload the payload to update @param [String] key the blob id or name @return [String]

# File lib/bucket_client/bucket.rb, line 106
def update_blob!(payload, key)
        result = update_blob payload, key
        raise BucketOperationException.new(result) unless result.success
        result.value
end