klahaeck
klahaeck

Reputation: 31

Rails send_file alternative with Rackspace Cloudfiles

I am trying to setup a download link for a file management system built on Rails 3 using the paperclip-cloudfiles gem. The send_file method works great when hosting files locally, but I need to use the Rackspace Cloudfiles system. I've tried setting the response headers and it seems to initialize the download, but the file is empty when finished.

here is my download function:

@file = UserFile.find(params[:id])

response.headers['Content-type'] = "#{@file.attachment_content_type}"
response.headers['Content-Disposition'] = "attachment;filename=\"#{@file.attachment_file_name}\""
response.headers['Content-Length'] = "#{@file.attachment_file_size}"
response.headers['Content-Description'] = 'File Transfer'
response.headers['Location'] = "#{@file.attachment.url(:original, false)}"

render :nothing => true

Am I doing this right?

I've also tried using just the ruby-cloudfiles library from Rackspace to download the object but no luck there as well.

Upvotes: 1

Views: 561

Answers (1)

MKumar
MKumar

Reputation: 1524

Use "send_data" method. It works for me.

Upvotes: 2

Related Questions