[Rails 3 - Ruby 1.9.2] I have to get email attachments ( mp4 files ) and store them... I get easily all parts using Mail ( .... <Content-Type: multipart/ mixed...."> ) attachment = mail.attachments[0] #<Mail::Part:2206885940, Multipart: false, Headers: <Content- Type: video/mp4; name=landscape.mp4>, <Content-Transfer-Encoding: base64>, <Content-Disposition: attachment; filename=landscape.mp4>> got what I need, but trying to store this attachment in a temp file , I get an encoding error : File.open(filepath,File::CREAT|File::TRUNC|File::WRONLY,0644) { | f> f.write(attachment.body) } Encoding::UndefinedConversionError Exception: "\x80" from ASCII-8BIT to UTF-8 did I miss anything before writing the file ? or is it a known Ruby bug ? being an .mp4 attachment, it should be a binary file.. it comes as an UTF-8 ( Base64) ? , right... how should I write it as a binary too ? tfyh
Related topics
Topic | Replies | Views | Activity | |
---|---|---|---|---|
Encoding error when trying to write file | 0 | 124 | January 12, 2011 | |
ActionMailer: attachments with utf8 filenames? | 0 | 121 | March 25, 2008 | |
Rails 3.0.7 ActionMailer attachments | 0 | 101 | May 24, 2011 | |
mail attachments displayed strangly in Rails 3.1 | 0 | 136 | January 3, 2012 | |
Problem reading attachments in emails | 1 | 105 | September 5, 2007 |