I have a download link in my app from which users should be able to download files which are stored on s3. These files will be publicly accessible on urls which look somethi
The following is what ended up working well for me. Getting the raw data from the S3 object and then using send_data
to pass that on to the browser.
Using the aws-sdk
gem documentation found here http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/S3Object.html
full controller method
def download
AWS.config({
access_key_id: "SECRET_KEY",
secret_access_key: "SECRET_ACCESS_KEY"
})
send_data(
AWS::S3.new.buckets["S3_BUCKET"].objects["FILENAME"].read, {
filename: "NAME_YOUR_FILE.pdf",
type: "application/pdf",
disposition: 'attachment',
stream: 'true',
buffer_size: '4096'
}
)
end