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 %>
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?