Uploading Videos to S3 with Carrierwave and Fog

你。 提交于 2019-12-25 03:33:19

问题


I have configured my testapp with Carrierwave and Fog. My goal is to upload videos to Amazon S3 but if I try to upload a video I get an error "pipe broken". It works if I'm just uploading a picture, so my Amazon configs should be ok!

Does carrierwave works for videos? Or why does it work for images and not for videos?

Carrierwave.rb:

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',
    :aws_access_key_id      => 'XXX',
    :aws_secret_access_key  => 'YYY'

  }
  config.fog_directory  = 'testbucket'
end

Video_Uploader.rb:

class VideoUploader < CarrierWave::Uploader::Base
  storage :fog
end

upload_form:

<%= form_for @video do |f| %>
    <div class="field">
      <%= f.label :name %><br />
      <%= f.text_field :name %>
    </div>
    <div class="field">
      <%= f.file_field :video %>
    </div>
    <div class="actions">
      <%= f.submit %>
    </div>
<% end %>

Controller:

def create
  @video = Video.new(params[:video])
    if @video.save
    redirect_to videos_url
  else
    render :new
  end
end

来源:https://stackoverflow.com/questions/16267259/uploading-videos-to-s3-with-carrierwave-and-fog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!