jquery_file_download-rails
jquery.fileDownload.js
package for Rails 3.1+ asset pipeline.
Installation
- Add
jquery_file_download-rails
to your application'sGemfile
:
gem 'jquery_file_download-rails'
- Run Bundler to lock the gem:
bundle install
- Add a reference to the gem's assets to your application's JavaScript asset
manifest (usually
app/assets/javascripts/application.js
):
//= require jquery.fileDownload
- Actions sending files in response to download requests must set the
fileDownload
cookie which can be done via thecookies
collection as in this sample controller:
class DownloadController < ApplicationController
def some_file
['fileDownload'] = 'true'
send_file 'path-to-file-on-server',
:filename => 'browser-download-file-name',
:type => 'content-type',
:x_sendfile => true
end
end
Samples
- See jquery_file_download-rails-samples for detailed step-by-step instructions and sample application.
Usage
With the gem installed, the $.fileDownload
jQuery plugin is available in the browser.
More details
Licence
jquery_file_download-rails
is released under the MIT licence.