Class: Lcms::Engine::S3Service
- Inherits:
-
Object
- Object
- Lcms::Engine::S3Service
- Defined in:
- app/services/lcms/engine/s3_service.rb
Class Method Summary collapse
- .create_object(key) ⇒ Object
-
.upload(key, data, options = {}) ⇒ String
Upload data to the specified resource by key.
- .url_for(key) ⇒ Object
Class Method Details
.create_object(key) ⇒ Object
8 9 10 11 12 13 |
# File 'app/services/lcms/engine/s3_service.rb', line 8 def self.create_object(key) ::Aws::S3::Resource .new(region: ENV.fetch('AWS_REGION')) .bucket(ENV.fetch('AWS_S3_BUCKET_NAME')) .object(key) end |
.upload(key, data, options = {}) ⇒ String
Upload data to the specified resource by key
24 25 26 27 28 29 30 31 |
# File 'app/services/lcms/engine/s3_service.rb', line 24 def self.upload(key, data, = {}) object = create_object key = .merge( body: data ) object.put() object.public_url end |
.url_for(key) ⇒ Object
33 34 35 |
# File 'app/services/lcms/engine/s3_service.rb', line 33 def self.url_for(key) create_object(key).public_url end |