【问题标题】:Rails, Download from BLOB databaseRails,从 BLOB 数据库下载
【发布时间】:2011-07-24 06:08:33
【问题描述】:

我有一个问题 我将上传数据保存在数据库中的 blob 文件类型中..

现在我想下载它..

如何管理

我尝试过这种方式(document_file 是一个带有 blob 数据的字段)

send_file @attachment.document_file, :disposition => '附件'

但出现错误...

有人可以帮忙吗?

谢谢:)

【问题讨论】:

  • 能否请您发布错误?

标签: ruby-on-rails sendfile


【解决方案1】:

也许您应该对 blob 数据使用 send_data 而不是 send_file:

send_data @attachment.document_file, :disposition => 'attachment'

考虑到 'attachment' 是默认值,所以你可以省略它。您应该收到此错误,因为 send_file 需要文件路径作为参数,而不是 blob。

你也可以看看:http://api.rubyonrails.org/classes/ActionController/Streaming.html#method-i-send_data

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-06
    • 2021-11-19
    • 2016-09-02
    • 2021-06-02
    • 1970-01-01
    • 2017-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多