0

嗨,我正在尝试将视频上传到 s3 并使用 flowplayer 显示它

我的 flowplayer 崩溃了,因为数字被添加到 video src 的 url 后面

<div class="flowplayer" style="width: 624px; height: 260px; ">
   <video src="http://s3-ap-southeast-1.amazonaws.com/psyched-sg-store/624x260.mp4?1350552718"></video>
</div>

这打破了我的 flowplayer ,但是在查看源代码后单击链接将我带到视频

<div class="flowplayer" style="width: 624px; height: 260px; ">
   <video src="http://s3-ap-southeast-1.amazonaws.com/psyched-sg-store/624x260.mp4"></video>
</div>

这行得通

我像这样设置我的回形针

# /config/initializer/s3.rb
# if you're using sg buckets
Paperclip.interpolates(:s3_sg_url) { |attachment, style|
   "#{attachment.s3_protocol}//s3-ap-southeast-1.amazonaws.com/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/},
   "")}"
   }

在我的模型中..

  has_attached_file :attached_video,:storage => :s3,
       :s3_credentials => "#{Rails.root}/config/s3.yml",
       :path => "/:filename",
       :url  => ":s3_sg_url"

       def attached_video_url
           if attached_video.file?
            attached_video.url
          else
            nil
        end    
      end

我还设置了我的 s3.yml

development:
  bucket: psyched-sg-store
  access_key_id: xx
  secret_access_key: xx
test:
  bucket: psyched-sg-store
  access_key_id: xx
  secret_access_key: x
production:
  bucket: psyched-sg-store
  access_key_id: xx
  secret_access_key: xx

怎么了?为什么数字出现在网址后面?

4

1 回答 1

1

这些数字是反缓存时间戳。如果您想摆脱它们,请添加:use_timestamp => false到模型的附件设置中,如下所示:

has_attached_file :attached_video,:storage => :s3,
       :s3_credentials => "#{Rails.root}/config/s3.yml",
       :path => "/:filename",
       :url  => ":s3_sg_url",
       :use_timestamp => false
于 2012-10-18T10:31:03.220 回答