Reputation: 691
Want to download S3 Signed Video file...but instead of download its going to playing...
Using send_data S3 download
send_data open(file).read, filename: 'archive12.mp4', type: 'video/mp4', disposition: 'attachment'
Upvotes: 0
Views: 888
Reputation: 724
You are using open(file).read
. Hence it reads the file and plays it. Maybe remove the .read
. Try adding the stream
flag. Look at send_file
too: https://api.rubyonrails.org/classes/ActionController/DataStreaming.html#method-i-send_file .
OR Use the aws-sdk maybe?
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')
If you still want to use send_data
, maybe try:
data = open("https://s3.amazonaws.com/PATTH TO YOUR FILE")
send_data data.read, filename: 'archive12.mp4', stream: false, type: 'video/mp4', disposition: 'attachment'
Upvotes: 2