I can successfully receive email from SendGrid and process its data.
My problem is the emails attachments.
When I look at what is posted for each attachment I get something in the lines of:
"attachment12"=>#<ActionDispatch::Http::UploadedFile:0x00000008a793f8
@original_filename="image036.png",
@content_type="image/png",
@headers="Content-Disposition: form-data;
name=\"attachment12\";
filename=\"image036.png\"\r\n
Content-Type: image/png\r\n",
@tempfile=#<File:/tmp/RackMultipart20120620-35076-1xav4k1>
>
Rather than the
Array
(
[attachment1] => Array
(
[name] => Upload.csv
[type] => text/csv
[tmp_name] => /tmp/phpo34iHI
[error] => 0
[size] => 76
)
)
Which is quoted in the Parse API shown enter link description here
Obviously, Rails is being elegant as always.
However, my questions are:
- Where are the files, where they downloaded as implied? I cannot find them (I would be worried if this happened)
I am actually reading into ActionDispatch::Http::UploadedFile, according to the docs I should be able to do params[‘attachment12’].read
I will post my findings
- Production is Heroku so I would need to either stick the files in some sort of container like the DB, Mongo or S3
- I am guessing the file is actually at sendgrid but their support does not understand my question and revert me back to the parse api! There is probably a URL but I cannot get to the bottom of it with their support. Unfortunately.
The files are actually POSTed to your server but you get an
ActionDispatch::Http::UploadedFileto work with. If you take a look at the class description you can see you have a couple of things available to you:The
original_filenameattribute obviously, but you can use.readto actually read out the contents and save it or you can probably pass the tempfile directly to whatever gem you are using.If you can tell me what kind of upload solution you use (paperclip, carrierwave) if any, I can help you a bit better.