【发布时间】:2015-06-11 15:55:22
【问题描述】:
我不知道如何通过send_file设置内容长度。
我检查了 api,没有 content-length 参数。
【问题讨论】:
我不知道如何通过send_file设置内容长度。
我检查了 api,没有 content-length 参数。
【问题讨论】:
您可以为响应设置标题,例如:
def download
@file = Attachment.find params[:id]
response.headers['Content-Length'] = @file.size.to_s
send_file @file.path, :x_sendfile => true
end
您可以在official docs 上找到有关响应对象的更多信息。
P.S: Header 需要是一个字符串才能与某些网络服务器正常工作。
【讨论】:
error.log 和 access.log 以获取更多信息。