Skip to content

A Rails addition which will allow sending of files with appropriate range headers

License

Notifications You must be signed in to change notification settings

metalels/send_file_with_range

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A Rails addition which will allow sending of files with appropriate range headers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%