Class: PdfMage::Workers::UploadFile
- Defined in:
- lib/pdf_mage/workers/upload_file.rb
Overview
A Sidekiq job that uploads a rendered PDF to Amazon S3.
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#ensure_directory_exists_for_pdf, #pdf_filename, #secretize_url, #string_exists?, #strip_string
Instance Method Details
#perform(pdf_id, callback_url = nil, meta = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pdf_mage/workers/upload_file.rb', line 12 def perform(pdf_id, callback_url = nil, = nil) validate_aws_config! s3 = Aws::S3::Resource.new( access_key_id: CONFIG.aws_account_key, region: CONFIG.aws_account_region, secret_access_key: CONFIG.aws_account_secret ) obj = s3.bucket(CONFIG.aws_account_bucket).object(pdf_id) obj.upload_file(pdf_filename(pdf_id)) pdf_url = obj.presigned_url(:get, expires_in: CONFIG.aws_presigned_url_duration) `rm #{pdf_filename(pdf_id)}` if CONFIG.delete_file_on_upload PdfMage::Workers::SendWebhook.perform_async(pdf_url, callback_url, ) if string_exists?(callback_url) end |