Coder Social home page Coder Social logo

telvue / telvue_send_file_with_range Goto Github PK

View Code? Open in Web Editor NEW

This project forked from metalels/send_file_with_range

0.0 0.0 0.0 3 KB

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

License: MIT License

Ruby 100.00%

telvue_send_file_with_range's Introduction

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

telvue_send_file_with_range's People

Contributors

blzabub avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.