Module: Reports::Uploader
- Defined in:
- lib/reports/uploader.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_s3_link(report_file) ⇒ Object private
- #new_s3_resource ⇒ Object private
- #s3_bucket ⇒ Object private
Class Method Details
.get_s3_link(report_file) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/reports/uploader.rb', line 19 def get_s3_link(report_file) s3_resource = new_s3_resource obj = s3_resource.bucket(s3_bucket).object("#{SecureRandom.uuid}.csv") obj.upload_file(report_file, content_type: 'text/csv') obj.presigned_url(:get, expires_in: 1.week.to_i) end |
.new_s3_resource ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/reports/uploader.rb', line 11 def new_s3_resource Aws::S3::Resource.new( region: Settings.reports.aws.region, access_key_id: Settings.reports.aws.access_key_id, secret_access_key: Settings.reports.aws.secret_access_key ) end |
.s3_bucket ⇒ Object
7 8 9 |
# File 'lib/reports/uploader.rb', line 7 def s3_bucket Settings.reports.aws.bucket end |
Instance Method Details
#get_s3_link(report_file) ⇒ Object (private)
19 20 21 22 23 24 |
# File 'lib/reports/uploader.rb', line 19 def get_s3_link(report_file) s3_resource = new_s3_resource obj = s3_resource.bucket(s3_bucket).object("#{SecureRandom.uuid}.csv") obj.upload_file(report_file, content_type: 'text/csv') obj.presigned_url(:get, expires_in: 1.week.to_i) end |
#new_s3_resource ⇒ Object (private)
11 12 13 14 15 16 17 |
# File 'lib/reports/uploader.rb', line 11 def new_s3_resource Aws::S3::Resource.new( region: Settings.reports.aws.region, access_key_id: Settings.reports.aws.access_key_id, secret_access_key: Settings.reports.aws.secret_access_key ) end |
#s3_bucket ⇒ Object (private)
7 8 9 |
# File 'lib/reports/uploader.rb', line 7 def s3_bucket Settings.reports.aws.bucket end |