Class: Fog::Storage::K5::File
- Inherits:
-
Model
- Object
- Model
- Fog::Storage::K5::File
show all
- Includes:
- K5::Shared
- Defined in:
- lib/fog/storage/k5/models/file.rb
Constant Summary
Constants included
from K5::Shared
K5::Shared::K5_URL_SCHEME, K5::Shared::K5_URL_SUFFIX
Instance Method Summary
collapse
Methods included from K5::Shared
#build_url, #refresh_auth_token_if_expired
Instance Method Details
#destroy ⇒ Object
14
15
16
17
18
|
# File 'lib/fog/storage/k5/models/file.rb', line 14
def destroy
requires :directory, :key
service.delete_object(directory.key, key)
true
end
|
#public_url ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/fog/storage/k5/models/file.rb', line 20
def public_url
requires :directory, :key
region = service.k5_region
project_id = service.k5_project_id
version = K5_STORAGE_URL_VERSION
url = build_url(url_type: K5_STORAGE_URL_TYPE, region: region)
container = directory.key
escaped_key = Excon::Utils.escape_uri(key)
"#{url}/#{version}/AUTH_#{project_id}/#{container}/#{escaped_key}"
end
|
#save ⇒ Object
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/fog/storage/k5/models/file.rb', line 33
def save
requires :body, :directory, :key
service.put_object(directory.key, key, body)
self.content_length = Fog::Storage.get_body_size(body)
self.content_type ||= Fog::Storage.get_cotent_type(body)
true
end
|