0

video_uploader.rb

class VideoUploader < CarrierWave::Uploader::Base
  include CarrierWaveDirect::Uploader
  alias_method :extension_white_list, :extension_whitelist
  def will_include_content_type
    true
  end
  default_content_type  'video/mp4'
  allowed_content_types %w(video/mpeg video/mp4 video/ogg)
end

Model.rb

class Video < ActiveRecord::Base
  mount_uploader :videosub, VideoUploader
end

Parameters:

"videosub"=>#<ActionDispatch::Http::UploadedFile:0x007f87201e28 @tempfile=#<Tempfile:/tmp/RackMultipart20170509-4704-1mjrwq.mp4>, @original_filename="168C7704-4337-A870-007B2CB22519.mp4", @content_type="video/mp4

Error showing is:

Validation failed: Videosub is invalid. 

And if I replace the code inside VideoUploader as:

class VideoUploader < CarrierWave::Uploader::Base
  include CarrierWaveDirect::Uploader
  alias_method :extension_white_list, :extension_whitelist
  storage :fog 
end

Then the file is being successfully being uploaded to S3. But in my case I need to upload the video in background and directly to S3 bypassing the server on which the app is hosted.

Please help!

Syed Asad Abbas Zaidi
  • 1,006
  • 1
  • 17
  • 32

1 Answers1

0

Found the solution: Earlier I was including the gem by defining the github path of the repo. Later on I just eliminated the path. And it worked.

Syed Asad Abbas Zaidi
  • 1,006
  • 1
  • 17
  • 32