class BucketClient::DigitalOceanBucket
Attributes
key[R]
Public Class Methods
new(region, http, client, key)
click to toggle source
@param [String] region the region of the bucket @param [DigitalOceanHttpClient] http the Digital Ocean http client @param [DigitalOceanClient] client the parent client @param [String] key the key of this bucket
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 10 def initialize(region, http, client, key) @region = region @http = http @bucket_client = client @key = key end
Public Instance Methods
create_blob(payload, key)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 62 def create_blob(payload, key) exist = exist_blob key if exist OperationResult.new false, "Blob already exist", nil, 400 else put_blob payload, key end end
delete_blob(key)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 75 def delete_blob(key) delete_blob_with_uri(get_uri key) end
delete_blob_if_exist(key)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 79 def delete_blob_if_exist(key) delete_blob_if_exist_with_uri(get_uri key) end
delete_blob_if_exist_with_uri(uri)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 46 def delete_blob_if_exist_with_uri(uri) @bucket_client.delete_blob_if_exist(uri) end
delete_blob_with_uri(uri)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 42 def delete_blob_with_uri(uri) @bucket_client.delete_blob(uri) end
exist_blob(key)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 54 def exist_blob(key) exist_blob_with_uri(get_uri key) end
exist_blob_with_uri(uri)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 25 def exist_blob_with_uri(uri) @bucket_client.exist_blob(uri) end
get_blob(key)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 50 def get_blob(key) get_blob_with_uri(get_uri key) end
get_blob_with_uri(uri)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 21 def get_blob_with_uri(uri) @bucket_client.get_blob uri end
get_uri(key)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 17 def get_uri(key) "https://#{@region}.digitaloceanspaces.com/#{@key}/#{key}" end
put_blob(payload, key)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 58 def put_blob(payload, key) put_blob_with_uri(payload, get_uri(key)) end
put_blob_with_uri(payload, uri)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 29 def put_blob_with_uri(payload, uri) @bucket_client.put_blob payload, uri end
update_blob(payload, key)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 71 def update_blob(payload, key) update_blob_with_uri(payload, get_uri(key)) end
update_blob_with_uri(payload, uri)
click to toggle source
# File lib/bucket_client/digital_ocean/digital_ocean_bucket.rb, line 33 def update_blob_with_uri(payload, uri) exist = exist_blob_with_uri uri if exist put_blob_with_uri payload, uri else OperationResult.new false, "Blob does not exist", nil, 400 end end