Class: CarrierWave::Storage::CloudFiles::File
- Defined in:
- lib/carrierwave/storage/cloud_files.rb
Instance Method Summary collapse
-
#content_type ⇒ Object
def metadata s3_object.metadata end.
- #content_type=(new_content_type) ⇒ Object
-
#delete ⇒ Object
Remove the file from Cloud Files.
-
#initialize(uploader, base, path) ⇒ File
constructor
A new instance of File.
-
#path ⇒ Object
Returns the current path/filename of the file on Cloud Files.
-
#read ⇒ Object
Reads the contents of the file from Cloud Files.
-
#store(data, headers = {}) ⇒ Object
Writes the supplied data into the object on Cloud Files.
-
#url ⇒ Object
Returns the url on the Cloud Files CDN.
Constructor Details
#initialize(uploader, base, path) ⇒ File
Returns a new instance of File.
30 31 32 33 34 |
# File 'lib/carrierwave/storage/cloud_files.rb', line 30 def initialize(uploader, base, path) @uploader = uploader @path = path @base = base end |
Instance Method Details
#content_type ⇒ Object
def metadata
s3_object.
end
83 84 85 |
# File 'lib/carrierwave/storage/cloud_files.rb', line 83 def content_type cf_container.object(@path).content_type end |
#content_type=(new_content_type) ⇒ Object
87 88 89 |
# File 'lib/carrierwave/storage/cloud_files.rb', line 87 def content_type=(new_content_type) headers["content-type"] = new_content_type end |
#delete ⇒ Object
Remove the file from Cloud Files
63 64 65 |
# File 'lib/carrierwave/storage/cloud_files.rb', line 63 def delete cf_container.delete_object(@path) end |
#path ⇒ Object
Returns the current path/filename of the file on Cloud Files.
Returns
- String
-
A path
43 44 45 |
# File 'lib/carrierwave/storage/cloud_files.rb', line 43 def path @path end |
#read ⇒ Object
Reads the contents of the file from Cloud Files
Returns
- String
-
contents of the file
54 55 56 57 58 |
# File 'lib/carrierwave/storage/cloud_files.rb', line 54 def read object = cf_container.object(@path) @content_type = object.content_type object.data end |
#store(data, headers = {}) ⇒ Object
Writes the supplied data into the object on Cloud Files.
Returns
boolean
98 99 100 101 |
# File 'lib/carrierwave/storage/cloud_files.rb', line 98 def store(data,headers={}) object = cf_container.create_object(@path) object.write(data,headers) end |
#url ⇒ Object
Returns the url on the Cloud Files CDN. Note that the parent container must be marked as public for this to work.
Returns
- String
-
file’s url
75 76 77 |
# File 'lib/carrierwave/storage/cloud_files.rb', line 75 def url cf_container.object(@path).public_url end |