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 %>
<fieldset>
<legend>Upload a file</legend>
<div class="form_row">
<%= file_field :attachment_metadata, :uploaded_data %>
</div>
<%= render :partial => "user/submit_button", :locals =>
:button =>
"submit_button.png" } %>
</fieldset>
<% 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?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---