Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4506 (closed defect: invalid)

Opened 4 years ago

Last modified 3 years ago

Base64-encoded binary attachments corrupted on Windows

Reported by: scribbs@kckcc.edu Assigned to: jamis@37signals.com
Priority: normal Milestone:
Component: ActionMailer Version:
Severity: normal Keywords: base64 binary attachment
Cc:

Description

Using ActionMailer in development mode, I attached a binary file to a mail message (it happened to be a Word document). The encoding corrupted the file such that when opening the attachment, Word could not recognize the character encoding. The resulting attachment also happened to be smaller than the original file.

However, when attempting this on a Linux machine, the file was encoded correctly and exhibited no problem when opened.

Using Rails 1.1, Ruby 1.8.4 (InstantRails)

Change History

03/30/06 15:12:11 changed by anonymous

  • keywords set to base64 binary attachment.

04/01/06 20:13:00 changed by david

  • owner changed from David to jamis@37signals.com.

09/09/06 18:32:21 changed by minam

  • status changed from new to closed.
  • resolution set to invalid.

Note that, on Windows, File.read('filename.doc') opens (and reads) the file in text mode. If you are using File.read to create the attachments, that's what the problem is. You can work around it by using:

  content = File.open('filename.doc', 'rb') { |f| f.read }

That will cause the file to be opened and read in binary mode.