Class: Caseflow::S3Service
- Inherits:
-
Object
- Object
- Caseflow::S3Service
- Defined in:
- app/services/caseflow/s3_service.rb
Class Method Summary collapse
- .fetch_content(filename) ⇒ Object
- .fetch_file(filename, dest_filepath) ⇒ Object
- .store_file(filename, content_or_filepath, type = :content) ⇒ Object
Class Method Details
.fetch_content(filename) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/caseflow/s3_service.rb', line 27 def self.fetch_content(filename) init! @client.get_object( bucket: bucket_name, key: filename ).body.read rescue Aws::S3::Errors::NoSuchKey nil end |
.fetch_file(filename, dest_filepath) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/services/caseflow/s3_service.rb', line 17 def self.fetch_file(filename, dest_filepath) init! @client.get_object( response_target: dest_filepath, bucket: bucket_name, key: filename ) end |
.store_file(filename, content_or_filepath, type = :content) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'app/services/caseflow/s3_service.rb', line 6 def self.store_file(filename, content_or_filepath, type = :content) init! content = (type == :content) ? content_or_filepath : File.open(content_or_filepath, "rb") @bucket.put_object(acl: "private", key: filename, body: content, server_side_encryption: "AES256") end |