carrivewave 上传之后默认是存放到 public 目录下的,现在我修改了存放目录,具体配置如下
CarrierWave.configure do |config|
# These permissions will make dir and files available only to the user running
# the servers
config.permissions = 0660
config.directory_permissions = 0760
config.storage = :file
# This avoids uploaded files from saving to public/ and so
# they will not be available for public (non-authenticated) downloading
#config.root = Rails.root
config.root = "/home/av_data"
end
原先预览视频的代码如下
<%= videojs_rails sources: { mp4: URI.decode(@video.file.url) }, poster:image_path("view.png"), id:"video_preview" %>
改过 carrivewave 存放位置之后没法访问了,原因是原来在浏览器中输入http://mysite.com/video.mp4 是可以直接访问到 public 目录下的存放的 video.mp4 的,现在目录换了,Rails 应该是能改哪个配置参数就能访问到新的存放目录下的文件。