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.
-
#identifier ⇒ Object
Returns the filename on S3.
-
#initialize(path, identifier) ⇒ 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(path, identifier) ⇒ File
Returns a new instance of File.
48 49 50 51 |
# File 'lib/carrierwave/storage/s3.rb', line 48 def initialize(path, identifier) @path = path @identifier = identifier end |
Instance Method Details
#about ⇒ Object
108 109 110 |
# File 'lib/carrierwave/storage/s3.rb', line 108 def about s3_object.about end |
#content_disposition ⇒ Object
124 125 126 |
# File 'lib/carrierwave/storage/s3.rb', line 124 def content_disposition s3_object.content_disposition end |
#content_disposition=(new_disposition) ⇒ Object
128 129 130 |
# File 'lib/carrierwave/storage/s3.rb', line 128 def content_disposition=(new_disposition) s3_object.content_disposition = new_disposition end |
#content_type ⇒ Object
116 117 118 |
# File 'lib/carrierwave/storage/s3.rb', line 116 def content_type s3_object.content_type end |
#content_type=(new_content_type) ⇒ Object
120 121 122 |
# File 'lib/carrierwave/storage/s3.rb', line 120 def content_type=(new_content_type) s3_object.content_type = new_content_type end |
#delete ⇒ Object
Remove the file from Amazon S3
89 90 91 |
# File 'lib/carrierwave/storage/s3.rb', line 89 def delete AWS::S3::S3Object.delete @path, bucket end |
#identifier ⇒ Object
Returns the filename on S3
Returns
- String
-
path to the file
71 72 73 |
# File 'lib/carrierwave/storage/s3.rb', line 71 def identifier @identifier end |
#metadata ⇒ Object
112 113 114 |
# File 'lib/carrierwave/storage/s3.rb', line 112 def s3_object. end |
#path ⇒ Object
Returns the current path of the file on S3
Returns
- String
-
A path
60 61 62 |
# File 'lib/carrierwave/storage/s3.rb', line 60 def path @path end |
#read ⇒ Object
Reads the contents of the file from S3
Returns
- String
-
contents of the file
82 83 84 |
# File 'lib/carrierwave/storage/s3.rb', line 82 def read AWS::S3::S3Object.value @path, bucket end |
#s3_object ⇒ Object
136 137 138 |
# File 'lib/carrierwave/storage/s3.rb', line 136 def s3_object @s3_object ||= AWS::S3::S3Object.find(@path, bucket) end |
#store ⇒ Object
132 133 134 |
# File 'lib/carrierwave/storage/s3.rb', line 132 def store s3_object.store end |
#url ⇒ Object
Returns the url on Amazon’s S3 service
Returns
- String
-
file’s url
100 101 102 103 104 105 106 |
# File 'lib/carrierwave/storage/s3.rb', line 100 def url if CarrierWave::config[:s3][:cnamed] ["http://", bucket, @path].compact.join('/') else ["http://s3.amazonaws.com", bucket, @path].compact.join('/') end end |