Configuring Apache XSendFile
Configuring Moonshine to use Apache XSendFile for Rails 4.2.6
Steps
Step 1
rails plugin install git://github.com/railsmachine/moonshine_xsendfile.git
Step 2
In the Moonshine manifest.yml file add the configure and recipe directive:
configure :xsendfile => {:x_send_file_path => '/absolute/path/to/download/url'}
recipe :xsendfile
This will work even if you have subdirectories under the /are directory.
Step 3
In production.rb, uncomment the line:
config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
Step 4
You can now send files in Rails controller:
send_file '/absolute/path/to/download/url/file.pdf', type: 'application/pdf'
Summary
In this chapter, you learned how to configure XSendFile in Apache for sending files to the browser in Rails 4.2.6 apps.