Rasool
Rasool

Reputation: 183

How to render a Amazon s3 file in to rails

I have some files uploaded in Amazon S3 server and I am developing a new Rails app, I wanted those amazon s3 files to render in to my rails app, is there a way to render a file from amazon s3 in to my rails app just for viewing purpose ?

Please help.

Upvotes: 0

Views: 1063

Answers (1)

thomasstephn
thomasstephn

Reputation: 3835

Yes, you can look at the aws-sdk gem, which is the officially supported gem and which provides all of what you need for authentication purposes to access your bucket.

The documentation of the gem is very detailed, and once you have your auth set you can do something like the below to access your url:

s3 = Aws::S3::Resource.new(region: "your-region")
s3.bucket("bucket-name").object("key/for/object").presigned_url("get", expires_in: 3600)

Upvotes: 1

Related Questions