Class: CarrierWave::Storage::RightS3::File
- Defined in:
- lib/carrierwave/storage/right_s3.rb
Instance Method Summary collapse
- #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(file) ⇒ Object
def content_disposition s3_object.content_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.
49 50 51 52 53 54 |
# File 'lib/carrierwave/storage/right_s3.rb', line 49 def initialize(uploader, base, path) @uploader = uploader @path = path @base = base @headers = {'x-amz-acl' => uploader.s3_access_policy}.merge(uploader.s3_headers) end |
Instance Method Details
#content_type ⇒ Object
102 103 104 |
# File 'lib/carrierwave/storage/right_s3.rb', line 102 def content_type headers["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 = result[:headers] result[:object] end |
#store(file) ⇒ Object
def content_disposition
s3_object.content_disposition
end
110 111 112 113 |
# File 'lib/carrierwave/storage/right_s3.rb', line 110 def store(file) # File.open('/home/ivan/output', 'w') {|f| f.write(@path) } connection.put(bucket, @path, file.read,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://s3.amazonaws.com/", @uploader.s3_bucket, "/", @path].compact.join end end |