Attachment fu corrupting .doc on windows?

I implemented a file upload/download using attachment_fu, storing files
in the DB. I’m running Vista, I can get files in and out, but it looks
like I’m somehow ruining the formatting of Word .doc files. If I upload
a .doc file, then download it, Word thinks it’s in Japanese plain/text
or something. The actual contents of the document are intact, but the
formatting is off.

In my view I have

<% form_for(:attachment_metadata, :url => { :action => “save” }, :html
=> { :multipart => true }) do %>

Upload a file
<%= file_field :attachment_metadata, :uploaded_data %>
<%= render :partial => "user/submit_button", :locals => :button => "submit_button.png" } %> <% end %>

in my controller I have:

def save
@attachable_file =
AttachmentMetadata.new(params[:attachment_metadata])
@attachable_file.account_id = @account
if @account.attachment_metadatas << @attachable_file

end

def download
@attachment = AttachmentMetadata.find(params[:id])
@file = @attachment.db_file
send_data @file.data, :filename => @attachment.filename, :type =>
@attachment.content_type, :disposition => ‘attachment’
end

Has anyone else run into something like this?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs