Rails send_file 与 nginx

发布于 2024-10-11 02:03:25 字数 165 浏览 0 评论 0原文

我正在尝试通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离去的眼神 2024-10-18 02:03:25

我遇到了同样的问题,我查看了响应标头,发现响应类型被设置为 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_file

send_file file, :disposition => 'inline', :type => 'image/png'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文