开发者

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.attachme开发者_运维知识库nt_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.


Use "send_data" method. It works for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜