Class: BucketClient::AWSBucket
- Inherits:
-
Bucket
- Object
- Bucket
- BucketClient::AWSBucket
show all
- Defined in:
- lib/bucket_client/aws/aws_bucket.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from KeyMethod
#create_blob!, #delete_blob!, #delete_blob_if_exist!, #get_blob!, #put_blob!, #update_blob!
Methods included from UriMethod
#delete_blob_if_exist_with_uri!, #delete_blob_with_uri!, #get_blob_with_uri!, #put_blob_with_uri!, #update_blob_with_uri!
Constructor Details
#initialize(region, http, client, key) ⇒ AWSBucket
Returns a new instance of AWSBucket.
12
13
14
15
16
17
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 12
def initialize(region, http, client, key)
@region = region
@http = http
@bucket_client = client
@key = key
end
|
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
6
7
8
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 6
def key
@key
end
|
Instance Method Details
#create_blob(payload, key) ⇒ Object
64
65
66
67
68
69
70
71
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 64
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) ⇒ Object
77
78
79
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 77
def delete_blob(key)
delete_blob_with_uri(get_uri key)
end
|
#delete_blob_if_exist(key) ⇒ Object
81
82
83
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 81
def delete_blob_if_exist(key)
delete_blob_if_exist_with_uri(get_uri key)
end
|
#delete_blob_if_exist_with_uri(uri) ⇒ Object
48
49
50
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 48
def delete_blob_if_exist_with_uri(uri)
@bucket_client.delete_blob_if_exist(uri)
end
|
#delete_blob_with_uri(uri) ⇒ Object
44
45
46
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 44
def delete_blob_with_uri(uri)
@bucket_client.delete_blob(uri)
end
|
#exist_blob(key) ⇒ Object
56
57
58
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 56
def exist_blob(key)
exist_blob_with_uri(get_uri key)
end
|
#exist_blob_with_uri(uri) ⇒ Object
27
28
29
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 27
def exist_blob_with_uri(uri)
@bucket_client.exist_blob(uri)
end
|
#get_blob(key) ⇒ Object
52
53
54
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 52
def get_blob(key)
get_blob_with_uri(get_uri key)
end
|
#get_blob_with_uri(uri) ⇒ Object
23
24
25
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 23
def get_blob_with_uri(uri)
@bucket_client.get_blob uri
end
|
#get_uri(key) ⇒ Object
19
20
21
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 19
def get_uri(key)
"https://s3-#{@region}.amazonaws.com/#{@key}/#{key}"
end
|
#put_blob(payload, key) ⇒ Object
60
61
62
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 60
def put_blob(payload, key)
put_blob_with_uri(payload, get_uri(key))
end
|
#put_blob_with_uri(payload, uri) ⇒ Object
31
32
33
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 31
def put_blob_with_uri(payload, uri)
@bucket_client.put_blob payload, uri
end
|
#update_blob(payload, key) ⇒ Object
73
74
75
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 73
def update_blob(payload, key)
update_blob_with_uri(payload, get_uri(key))
end
|
#update_blob_with_uri(payload, uri) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/bucket_client/aws/aws_bucket.rb', line 35
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
|