想下载S3签名视频文件...但是要下载它才能播放...
使用send_data S3下载
send_data open(file).read, filename: 'archive12.mp4', type: 'video/mp4', disposition: 'attachment'
答案 0 :(得分:0)
您正在使用open(file).read
。因此,它将读取文件并播放。也许删除.read
。尝试添加stream
标志。还要查看send_file
:https://api.rubyonrails.org/classes/ActionController/DataStreaming.html#method-i-send_file。
还是使用aws-sdk?
require 'aws-sdk'
s3 = Aws::S3::Resource.new(
region: 'us-east-1',
access_key_id: '...',
secret_access_key: '...'
)
s3.bucket('bucket-name').object('key').get(response_target: '/path/to/file')
如果您仍然想使用send_data
,请尝试:
data = open("https://s3.amazonaws.com/PATTH TO YOUR FILE")
send_data data.read, filename: 'archive12.mp4', stream: false, type: 'video/mp4', disposition: 'attachment'