Download video in rails app

I need a plugin to download videos in a rails application.

Can someone give me an idea on how to do this?

+5
source share
3 answers

Try paperclip gem, very popular for this purpose.

+1
source

You can also use carrierwavegem

  • Add to your Gemfile: gem 'carrierwave'

    Run bundle install

  • Create a bootloader to download the video using the carrier generator.

    rails g uploader video

  • Creates a file video_uploader.rbin a directoryuploaders

  • , , , add_{column}_to_{model}

    rails g migration add_video_to_post video:string

  • rake db:migrate

  • class Post < ActiveRecord::Base
          mount_uploader :video, VideoUploader  
    end
    
  • PostController

    class PostController < ApplicationController
          .
          . 
          .
          def post_params
              params.require(:post).permit(:name,:video)
          end
    end
    
  • _forml.html.erb, views/posts

    <%=f.file_field :video%>
    
  • /

    <% @posts.each do |post|%>
        <%= post.name %>
        <%= video_tag post.video_url.to_s :controls =>true %>
    <%end%>
    

https://github.com/carrierwaveuploader/carrierwave http://railscasts.com/episodes/253-carrierwave-file-uploads

+12

Even more specific, I created a Rails gem that works specifically with the video: https://rubygems.org/gems/paperclip-ffmpeg

+6
source

All Articles