Class: CarrierWave::Storage::RightS3::File
- Defined in:
- lib/carrierwave/storage/right_s3.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 Amazon S3.
-
#initialize(uploader, base, path) ⇒ File
constructor
A new instance of File.
-
#path ⇒ Object
Returns the current path of the file on S3.
-
#read ⇒ Object
Reads the contents of the file from S3.
-
#store(data) ⇒ Object
def content_disposition=(new_disposition) s3_object.content_disposition = new_disposition end.
-
#url ⇒ Object
Returns the url on Amazon’s S3 service.
Constructor Details
#initialize(uploader, base, path) ⇒ File
Returns a new instance of File.
50 51 52 53 54 |
# File 'lib/carrierwave/storage/right_s3.rb', line 50 def initialize(uploader, base, path) @uploader = uploader @path = path @base = base end |
Instance Method Details
#content_type ⇒ Object
def metadata
s3_object.
end
110 111 112 |
# File 'lib/carrierwave/storage/right_s3.rb', line 110 def content_type headers["content-type"] end |
#content_type=(new_content_type) ⇒ Object
114 115 116 |
# File 'lib/carrierwave/storage/right_s3.rb', line 114 def content_type=(new_content_type) headers["content-type"] = new_content_type end |
#delete ⇒ Object
Remove the file from Amazon S3
83 84 85 |
# File 'lib/carrierwave/storage/right_s3.rb', line 83 def delete connection.delete(bucket, @path) end |
#path ⇒ Object
Returns the current path of the file on S3
Returns
- String
-
A path
63 64 65 |
# File 'lib/carrierwave/storage/right_s3.rb', line 63 def path @path end |
#read ⇒ Object
Reads the contents of the file from S3
Returns
- String
-
contents of the file
74 75 76 77 78 |
# File 'lib/carrierwave/storage/right_s3.rb', line 74 def read result = connection.get(bucket, @path) headers["content-type"] = result[:headers]["content-type"] result[:object] end |
#store(data) ⇒ Object
def content_disposition=(new_disposition)
s3_object.content_disposition = new_disposition
end
126 127 128 |
# File 'lib/carrierwave/storage/right_s3.rb', line 126 def store(data) connection.put(bucket, @path, data, headers) end |
#url ⇒ Object
Returns the url on Amazon’s S3 service
Returns
- String
-
file’s url
94 95 96 97 98 99 100 |
# File 'lib/carrierwave/storage/right_s3.rb', line 94 def url if @uploader.s3_cnamed ["http://", @uploader.s3_bucket, @path].compact.join('/') else ["http://#{@uploader.s3_bucket}.s3.amazonaws.com", @path].compact.join('/') end end |