carrierwave 多文件上传和存储

carrierwave multiple file uploads and storing

我想用载波进行多文件上传。

上传时,我转码了多种格式的电影 .mp4 .mov ...

现在我想上传所有这些并将它们存储在数据库中吗?

如何使用载波保存文件的版本?

谢谢

将相关属性添加到您的模型并引入 before_save 回调。

class Video < ActiveRecord::Base
  mount_uploader :video, VideoUploader

  before_save :update_video_attributes
  private

  def update_video_attributes
    if video.present? && video_changed?
      self.content_type = video.file.content_type
      self.file_size = video.file.size
    end
  end
end

有关详细信息,请参阅 github