2011-11-01 68 views
3

我已经设置了一个路径来处理特定的文件下载。Rails 3.0.x send_file发送404 HTML而不是真实文件

match '/overview' => "pages#overview", :as => "da_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 

不过,当我打的网址http://mysite.com/overview,浏览器下载overview.pdf.html和HTML文件说404: Requested URL /overview not found on this server

我检查文件是否存在。 pdf文件是/ public/downloads目录。我缺少什么配置?请帮忙。

回答

2

根据您正在运行的mod_xsendfile的版本,您需要在“XSendFile on”之后添加以下内容之一,以提供访问文件系统上文件的mod_xsendfile权限。

mod_xsendfile 0.9:

XSendFileAllowAbove on

mod_xsendfile> 0.9:

XSendFilePath "/path/where/files/you're/sending/are"

相关问题