# Attachment\_fu and S3 -- cannot download file correctly

**URL:** <https://www.ruby-forum.com/t/attachment-fu-and-s3-cannot-download-file-correctly/123565>\
**Category:** Rails\
**Created:** [December 18, 2007, 8:40pm UTC](https://www.ruby-forum.com/t/attachment-fu-and-s3-cannot-download-file-correctly/123565 "2007-12-18T20:40:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [December 18, 2007, 8:40pm UTC](https://www.ruby-forum.com/t/attachment-fu-and-s3-cannot-download-file-correctly/123565/1 "2007-12-18T20:40:22Z")

</div>

I don’t know why this isn’t working. If I download a word doc that I  
uploaded, all I get is the S3 file path in the document. If I access  
the s3 file path directly in my browser, it downloads the file  
correctly.

Here is my controller method:

def download  
@curriculum = @school.curriculums.find(params[:id])  
send\_data @curriculum.attachment.public\_filename,  
:filename =\> @curriculum.attachment.filename,  
:type =\> @curriculum.attachment.content\_type  
end

view:

link\_to curriculum.attachment.filename.split(’.’).first, :action =\>  
‘download’, :id =\> curriculum.id

The file is downloaded, but not the file content. Thanks for any help!

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [December 18, 2007, 9:14pm UTC](https://www.ruby-forum.com/t/attachment-fu-and-s3-cannot-download-file-correctly/123565/2 "2007-12-18T21:14:54Z")

</div>

you are trying to call send\_data which will send a string to the  
browser, so you are just sending the string of the url. try this:

def download  
@curriculum = @school.curriculums.find(params[:id])  
redirect\_to @curriculum.public\_filename  
end

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [December 18, 2007, 9:56pm UTC](https://www.ruby-forum.com/t/attachment-fu-and-s3-cannot-download-file-correctly/123565/3 "2007-12-18T21:56:33Z")

</div>

That worked! Thanks a lot.
