Class: Neofiles::DataStore::AmazonS3
- Inherits:
-
Object
- Object
- Neofiles::DataStore::AmazonS3
- Defined in:
- app/models/neofiles/data_store/amazon_s3.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#md5 ⇒ Object
readonly
Returns the value of attribute md5.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id) ⇒ AmazonS3
constructor
A new instance of AmazonS3.
- #write(data) ⇒ Object
Constructor Details
#initialize(id) ⇒ AmazonS3
31 32 33 |
# File 'app/models/neofiles/data_store/amazon_s3.rb', line 31 def initialize(id) @id = id end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
29 30 31 |
# File 'app/models/neofiles/data_store/amazon_s3.rb', line 29 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
29 30 31 |
# File 'app/models/neofiles/data_store/amazon_s3.rb', line 29 def id @id end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
29 30 31 |
# File 'app/models/neofiles/data_store/amazon_s3.rb', line 29 def length @length end |
#md5 ⇒ Object (readonly)
Returns the value of attribute md5.
29 30 31 |
# File 'app/models/neofiles/data_store/amazon_s3.rb', line 29 def md5 @md5 end |
Class Method Details
.bucket_name ⇒ Object
14 15 16 |
# File 'app/models/neofiles/data_store/amazon_s3.rb', line 14 def self.bucket_name Rails.application.config.neofiles.amazon_s3_bucket end |
.find(id) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/models/neofiles/data_store/amazon_s3.rb', line 18 def self.find(id) s3_object = new(id) if s3_object.data s3_object else raise Neofiles::DataStore::NotFoundException end end |
Instance Method Details
#write(data) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/models/neofiles/data_store/amazon_s3.rb', line 56 def write(data) if data.is_a? Tempfile data.flush data.rewind data = data.read end client.put_object( body: data, bucket: bucket_name, key: s3_key ) @data = data end |