Reputation: 10400
I have setup a route to handle a specific file download.
match '/overview' => "pages#overview", :as => "da_overview"
in Pages#overview, I'm sending the file with this line
send_file File.join(Rails.root, 'public', 'downloads', 'overview.pdf'), :type =>"application/pdf"
I've switched on the x-sendfile setting.
config.action_dispatch.x_sendfile_header = "X-Sendfile"
Also, I've installed and enabled mod_xsendfile module in the apache server. I have enabled it for my site as well.
XSendFile on
Still, when I hit the url http://mysite.com/overview, the browser is downloading overview.pdf.html
and the HTML file says 404: Requested URL /overview not found on this server
I've checked the file existence. The pdf file is /public/downloads directory. What configuration am i missing? Please help.
Upvotes: 3
Views: 1385
Reputation: 101
Depending on the version of mod_xsendfile that you're running you'll need to add one of the following after "XSendFile on" to give mod_xsendfile permissions to access files on your filesystem.
mod_xsendfile 0.9:
XSendFileAllowAbove on
mod_xsendfile >0.9:
XSendFilePath "/path/where/files/you're/sending/are"
Upvotes: 2