Class: CarrierWave::Storage::UcloudFile
- Inherits:
-
CarrierWave::SanitizedFile
- Object
- CarrierWave::SanitizedFile
- CarrierWave::Storage::UcloudFile
- Defined in:
- lib/carrierwave/storage/ucloud_file.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #content_type ⇒ Object
- #content_type=(new_content_type) ⇒ Object
- #delete ⇒ Object
- #headers ⇒ Object
-
#initialize(uploader, base, path) ⇒ UcloudFile
constructor
A new instance of UcloudFile.
- #read ⇒ Object
- #store(file, headers = {}) ⇒ Object
- #url(opts = {}) ⇒ Object
Constructor Details
#initialize(uploader, base, path) ⇒ UcloudFile
Returns a new instance of UcloudFile.
6 7 8 9 10 11 |
# File 'lib/carrierwave/storage/ucloud_file.rb', line 6 def initialize(uploader, base, path) @uploader = uploader @path = path @base = base @bucket = ::CarrierWave::Ucloud::Bucket.new(uploader) end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
4 5 6 |
# File 'lib/carrierwave/storage/ucloud_file.rb', line 4 def bucket @bucket end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/carrierwave/storage/ucloud_file.rb', line 4 def path @path end |
Instance Method Details
#content_type ⇒ Object
31 32 33 |
# File 'lib/carrierwave/storage/ucloud_file.rb', line 31 def content_type headers[:content_type] end |
#content_type=(new_content_type) ⇒ Object
35 36 37 |
# File 'lib/carrierwave/storage/ucloud_file.rb', line 35 def content_type=(new_content_type) headers[:content_type] = new_content_type end |
#delete ⇒ Object
19 20 21 |
# File 'lib/carrierwave/storage/ucloud_file.rb', line 19 def delete bucket.delete(path) end |
#headers ⇒ Object
39 40 41 |
# File 'lib/carrierwave/storage/ucloud_file.rb', line 39 def headers @headers ||= {} end |
#read ⇒ Object
13 14 15 16 17 |
# File 'lib/carrierwave/storage/ucloud_file.rb', line 13 def read response = bucket.get(path) @headers = response.headers.deep_transform_keys { |k| k.underscore.to_sym rescue key } response.body end |
#store(file, headers = {}) ⇒ Object
27 28 29 |
# File 'lib/carrierwave/storage/ucloud_file.rb', line 27 def store(file, headers = {}) bucket.put(path, file, headers) end |
#url(opts = {}) ⇒ Object
23 24 25 |
# File 'lib/carrierwave/storage/ucloud_file.rb', line 23 def url(opts = {}) bucket.url(path, opts) end |