Class: Configuration::S3SourceStoreBase::S3Object
- Inherits:
-
Object
- Object
- Configuration::S3SourceStoreBase::S3Object
- Defined in:
- lib/httpimagestore/configuration/s3.rb
Direct Known Subclasses
Instance Method Summary collapse
- #content_type ⇒ Object
-
#initialize(client, bucket, key) ⇒ S3Object
constructor
A new instance of S3Object.
- #private_url ⇒ Object
- #public_url ⇒ Object
- #read(max_bytes = nil) ⇒ Object
- #s3_object ⇒ Object
- #write(data, options = {}) ⇒ Object
Constructor Details
#initialize(client, bucket, key) ⇒ S3Object
Returns a new instance of S3Object.
157 158 159 160 161 |
# File 'lib/httpimagestore/configuration/s3.rb', line 157 def initialize(client, bucket, key) @client = client @bucket = bucket @key = key end |
Instance Method Details
#content_type ⇒ Object
186 187 188 |
# File 'lib/httpimagestore/configuration/s3.rb', line 186 def content_type s3_object.head[:content_type] end |
#private_url ⇒ Object
178 179 180 |
# File 'lib/httpimagestore/configuration/s3.rb', line 178 def private_url s3_object.url_for(:read, expires: 60 * 60 * 24 * 365 * 20).to_s # expire in 20 years end |
#public_url ⇒ Object
182 183 184 |
# File 'lib/httpimagestore/configuration/s3.rb', line 182 def public_url s3_object.public_url.to_s end |
#read(max_bytes = nil) ⇒ Object
168 169 170 171 172 |
# File 'lib/httpimagestore/configuration/s3.rb', line 168 def read(max_bytes = nil) = {} [:range] = 0..max_bytes if max_bytes s3_object.read() end |
#s3_object ⇒ Object
163 164 165 166 |
# File 'lib/httpimagestore/configuration/s3.rb', line 163 def s3_object return @s3_object if @s3_object @s3_object = @client.buckets[@bucket].objects[@key] end |
#write(data, options = {}) ⇒ Object
174 175 176 |
# File 'lib/httpimagestore/configuration/s3.rb', line 174 def write(data, = {}) s3_object.write(data, ) end |