0
video_uploader.rb問題與Carrierwave_Direct +滑軌
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
參數:
"videosub"=>#<ActionDispatch::Http::UploadedFile:0x007f87201e28 @tempfile=#<Tempfile:/tmp/RackMultipart20170509-4704-1mjrwq.mp4>, @original_filename="168C7704-4337-A870-007B2CB22519.mp4", @content_type="video/mp4
錯誤表示爲:
Validation failed: Videosub is invalid.
如果我更換裏面VideoUploader代碼爲:
class VideoUploader < CarrierWave::Uploader::Base
include CarrierWaveDirect::Uploader
alias_method :extension_white_list, :extension_whitelist
storage :fog
end
然後該文件被成功上傳到S3。但在我的情況下,我需要在後臺將視頻直接上傳到S3,繞過託管應用程序的服務器。
請幫忙!