# Attachment fu corrupting .doc on windows?

**URL:** <https://www.ruby-forum.com/t/attachment-fu-corrupting-doc-on-windows/124554>\
**Category:** Rails\
**Created:** [December 30, 2007, 6:26am UTC](https://www.ruby-forum.com/t/attachment-fu-corrupting-doc-on-windows/124554 "2007-12-30T06:26:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![retcheto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a87d85/32.png) [@retcheto](https://www.ruby-forum.com/u/retcheto)\
**Post date:** [December 30, 2007, 6:26am UTC](https://www.ruby-forum.com/t/attachment-fu-corrupting-doc-on-windows/124554/1 "2007-12-30T06:26:35Z")

</div>

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?
