【发布时间】:2012-08-10 14:37:11
【问题描述】:
我已经设置了处理特定文件下载的路由。
match '/overview' => "pages#overview", :as => "da_overview"
在 Pages#overview 中,我用这一行发送文件
send_file File.join(Rails.root, 'public', 'downloads', 'overview.pdf'), :type =>"application/pdf"
我已经开启了 x-sendfile 设置。
config.action_dispatch.x_sendfile_header = "X-Sendfile"
另外,我已经在 apache 服务器中安装并启用了 mod_xsendfile 模块。我也为我的网站启用了它。
XSendFile on
不过,当我点击 url http://mysite.com/overview 时,浏览器正在下载 overview.pdf.html 并且 HTML 文件显示为 404: Requested URL /overview not found on this server
我已检查文件是否存在。 pdf 文件是 /public/downloads 目录。我缺少什么配置?请帮忙。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 apache download