Class: AssetCloud::GCSBucket
- Inherits:
-
Bucket
- Object
- Bucket
- AssetCloud::GCSBucket
show all
- Defined in:
- lib/asset_cloud/buckets/gcs_bucket.rb
Instance Attribute Summary
Attributes inherited from Bucket
#cloud, #name
Instance Method Summary
collapse
Methods inherited from Bucket
#initialize, #versioned?
Instance Method Details
#clear ⇒ Object
29
30
31
|
# File 'lib/asset_cloud/buckets/gcs_bucket.rb', line 29
def clear
bucket.files.each(&:delete)
end
|
#delete(key) ⇒ Object
24
25
26
27
|
# File 'lib/asset_cloud/buckets/gcs_bucket.rb', line 24
def delete(key)
file = find_by_key!(key)
file.delete
end
|
#ls(key = nil) ⇒ Object
5
6
7
|
# File 'lib/asset_cloud/buckets/gcs_bucket.rb', line 5
def ls(key = nil)
key ? find_by_key!(key) : bucket.files
end
|
#read(key) ⇒ Object
9
10
11
12
13
14
|
# File 'lib/asset_cloud/buckets/gcs_bucket.rb', line 9
def read(key)
file = find_by_key!(key)
downloaded = file.download
downloaded.rewind
downloaded.read
end
|
#stat(key) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/asset_cloud/buckets/gcs_bucket.rb', line 33
def stat(key)
begin
file = find_by_key!(key)
Metadata.new(true, file.size, file.created_at, file.updated_at)
rescue AssetCloud::AssetNotFoundError
Metadata.new(false)
end
end
|
#write(key, data, options = {}) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/asset_cloud/buckets/gcs_bucket.rb', line 16
def write(key, data, options = {})
bucket.create_file(
data,
absolute_key(key),
options
)
end
|