我有一个问题,我将上传的数据保存在数据库中的blob文件类型中。
现在我想要下载它。
如何管理呢?
我尝试了这种方式(document_file是一个包含blob数据的字段):
send_file @attachment.document_file, :disposition => 'attachment'
但是出现了错误...
有人能帮忙吗?
谢谢 :)
我有一个问题,我将上传的数据保存在数据库中的blob文件类型中。
现在我想要下载它。
如何管理呢?
我尝试了这种方式(document_file是一个包含blob数据的字段):
send_file @attachment.document_file, :disposition => 'attachment'
但是出现了错误...
有人能帮忙吗?
谢谢 :)
send_data @attachment.document_file, :disposition => 'attachment'
考虑到“attachment”是默认值,因此您可以省略它。您应该会收到此错误,因为send_file需要一个文件路径作为参数,而不是一个blob。
您还可以查看:http://api.rubyonrails.org/classes/ActionController/Streaming.html#method-i-send_data