Rails send_file 与 nginx
我正在尝试通过 Rails 3 中的 send_file 发送文件...该文件已找到并且似乎也已发送,但由于某种原因未收到...
即使 :disposition =>设置'inline'后,浏览器总是显示“下载框”...
在nginxconf中,sendfile设置为on...
I am trying to send a file via send_file, in rails 3... The file is found and is seemingly sent too, but for some reason it is not received...
Also even though :disposition => 'inline' is set, the browser always shows a "download box"...
In nginx conf, sendfile is set to on...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,我查看了响应标头,发现响应类型被设置为
application/octet-stream
。尝试在调用send_file时设置文件的mime类型send_file file, :disposition => '内联', :type => '图像/png'
I had the same problem, I looked at the response headers and saw the response type was being set as
application/octet-stream
. Try setting the file's mime type when calling send_filesend_file file, :disposition => 'inline', :type => 'image/png'
我建议你应该经历这个: 使用 x-sendfile 通过 Nginx via Rails 2.3 提供大文件
I suggest you should go through this: Serving Large Files Through Nginx via Rails 2.3 Using x-sendfile