chore: Add down gem for Local file downloads (#2765)

- Add down gem to handle downloading files to host machine
- Remove the LocalResource class
- Introduce max limit for contact avatars send via SDK
This commit is contained in:
Sojan Jose
2021-08-11 16:40:28 +05:30
committed by GitHub
parent 29f54c1f26
commit 8daf1fe033
11 changed files with 47 additions and 93 deletions

View File

@@ -93,7 +93,9 @@ class Twilio::IncomingMessageService
def attach_files
return if params[:MediaUrl0].blank?
file_resource = LocalResource.new(params[:MediaUrl0], params[:MediaContentType0])
attachment_file = Down.download(
params[:MediaUrl0]
)
attachment = @message.attachments.new(
account_id: @message.account_id,
@@ -101,13 +103,11 @@ class Twilio::IncomingMessageService
)
attachment.file.attach(
io: file_resource.file,
filename: file_resource.tmp_filename,
content_type: file_resource.encoding
io: attachment_file,
filename: attachment_file.original_filename,
content_type: attachment_file.content_type
)
@message.save!
rescue *ExceptionList::URI_EXCEPTIONS => e
Rails.logger.info "invalid url #{file_url} : #{e.message}"
end
end