【问题标题】:Rails send_file alternative with Rackspace CloudfilesRails send_file 替代 Rackspace Cloudfiles
【发布时间】:2011-08-09 17:07:22
【问题描述】:

我正在尝试使用 paperclip-cloudfiles gem 为基于 Rails 3 构建的文件管理系统设置下载链接。 send_file 方法在本地托管文件时效果很好,但我需要使用 Rackspace Cloudfiles 系统。我试过设置响应头,它似乎初始化了下载,但是完成后文件是空的。

这是我的下载功能:

@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

我这样做对吗?

我也试过只使用 Rackspace 的 ruby​​-cloudfiles 库来下载对象,但也没有运气。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 rackspace-cloud cloudfiles


    【解决方案1】:

    使用“send_data”方法。 它对我有用。

    【讨论】:

    • 谢谢!在生产服务器上运行良好,在我的本地开发机器上有点慢。我想这是意料之中的。
    猜你喜欢
    • 1970-01-01
    • 2013-07-18
    • 1970-01-01
    • 2018-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多