Class: CarrierWave::Storage::S3::File
- Defined in:
- lib/carrierwave/storage/s3.rb
Instance Method Summary collapse
- #about ⇒ Object
- #content_disposition ⇒ Object
- #content_disposition=(new_disposition) ⇒ Object
- #content_type ⇒ Object
- #content_type=(new_content_type) ⇒ Object
-
#delete ⇒ Object
Remove the file from Amazon S3.
-
#initialize(uploader, path) ⇒ File
constructor
A new instance of File.
- #metadata ⇒ Object
-
#path ⇒ Object
Returns the current path of the file on S3.
-
#read ⇒ Object
Reads the contents of the file from S3.
- #s3_object ⇒ Object
- #store ⇒ Object
-
#url ⇒ Object
Returns the url on Amazon’s S3 service.
Constructor Details
#initialize(uploader, path) ⇒ File
Returns a new instance of File.
70 71 72 73 |
# File 'lib/carrierwave/storage/s3.rb', line 70 def initialize(uploader, path) @uploader = uploader @path = path end |
Instance Method Details
#about ⇒ Object
119 120 121 |
# File 'lib/carrierwave/storage/s3.rb', line 119 def about s3_object.about end |
#content_disposition ⇒ Object
135 136 137 |
# File 'lib/carrierwave/storage/s3.rb', line 135 def content_disposition s3_object.content_disposition end |
#content_disposition=(new_disposition) ⇒ Object
139 140 141 |
# File 'lib/carrierwave/storage/s3.rb', line 139 def content_disposition=(new_disposition) s3_object.content_disposition = new_disposition end |
#content_type ⇒ Object
127 128 129 |
# File 'lib/carrierwave/storage/s3.rb', line 127 def content_type s3_object.content_type end |
#content_type=(new_content_type) ⇒ Object
131 132 133 |
# File 'lib/carrierwave/storage/s3.rb', line 131 def content_type=(new_content_type) s3_object.content_type = new_content_type end |
#delete ⇒ Object
Remove the file from Amazon S3
100 101 102 |
# File 'lib/carrierwave/storage/s3.rb', line 100 def delete AWS::S3::S3Object.delete @path, @uploader.s3_bucket end |
#metadata ⇒ Object
123 124 125 |
# File 'lib/carrierwave/storage/s3.rb', line 123 def s3_object. end |
#path ⇒ Object
Returns the current path of the file on S3
Returns
- String
-
A path
82 83 84 |
# File 'lib/carrierwave/storage/s3.rb', line 82 def path @path end |
#read ⇒ Object
Reads the contents of the file from S3
Returns
- String
-
contents of the file
93 94 95 |
# File 'lib/carrierwave/storage/s3.rb', line 93 def read AWS::S3::S3Object.value @path, @uploader.s3_bucket end |
#s3_object ⇒ Object
147 148 149 |
# File 'lib/carrierwave/storage/s3.rb', line 147 def s3_object @s3_object ||= AWS::S3::S3Object.find(@path, @uploader.s3_bucket) end |
#store ⇒ Object
143 144 145 |
# File 'lib/carrierwave/storage/s3.rb', line 143 def store s3_object.store end |
#url ⇒ Object
Returns the url on Amazon’s S3 service
Returns
- String
-
file’s url
111 112 113 114 115 116 117 |
# File 'lib/carrierwave/storage/s3.rb', line 111 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 |