Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using remote file as attachment in rails

I'm trying to pull a public AWS file and use it as an attachment, like so:

attachments['file.zip'] = open('https://s3.amazonaws.com/file.zip')

I'm getting a No such file or directory

I've changed the paths above to be generic, but I can indeed navigate to the AWS path and get a file. Is there a way to make it an attachement for use by ActionMailer?

like image 795
Slick23 Avatar asked Dec 16 '22 11:12

Slick23


1 Answers

attachments['file.zip'] = open('https://s3.amazonaws.com/file.zip').read

open returns an IO object, not the content of the file. You must give the file content to attachments.

like image 143
Michaël Witrant Avatar answered Dec 30 '22 05:12

Michaël Witrant