jquery_file_download-rails

Install gem Build status

jquery.fileDownload.js package for Rails 3.1+ asset pipeline.

Installation

  • Add jquery_file_download-rails to your application's Gemfile:
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 the cookies collection as in this sample controller:
class DownloadController < ApplicationController
  def some_file
    cookies['fileDownload'] = 'true'

    send_file 'path-to-file-on-server',
      :filename => 'browser-download-file-name',
      :type => 'content-type',
      :x_sendfile => true
  end
end

Samples

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.