2

I am using Aws S3 resource object of AWS SDK in my Rails code to download a file from my S3 bucket this way:

  s3 = Aws::S3::Resource.new(region: 'us-west-2')
  obj = s3.bucket('mybucket').object( my_report_file_name)
  obj.get(response_target: my_report_file_name)

The get method in the last line shown above downloads the file from S3 bucket to the Rails server machine. I would like to download the file to the client browser directly instead.

How can I achieve this?

m.beginner
  • 389
  • 2
  • 18

1 Answers1

0

If you can access the object, and you want to download it through the browser into the user's file directory, you might be looking for send_data:

send_data(obj, filename: 'my_report_file_name')

Grimhamr
  • 41
  • 6