A Rails addition which will allow sending of files with appropriate range headers
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
LICENCE
README.md
send_file_with_range.gemspec

README.md

send_file with Range

Rails includes a method called send_file which allows you to send a file from your Rails app to a browser. Some files, however, require that data can be requested in partial chunks with the client providing a range of bytes to be returned from the file. This is particularily previlent when streaming video over HTTP.

For example, if you have a video which you want to embed, you need to be able to return the video file in sections to the browser to allow users to skip through the video without downloading the whole file.

This little gem just extends Rails' send_file method to support this.

Installation

gem 'send_file_with_range'

Usage

To use this, you just need to pass the :range => true option to a normal send_file call.

class VideoController < ApplicationController

  def play
    path_to_video = Rails.root.join('data', 'some-video.mp4')
    send_file path_to_video, :range => true, :disposition => 'inline', :type => 'video/mp4's
  end

end