3
votes

I need to set direct link of files uploaded to AWS S3 server. I am using url_for(Model.first.image). But it first links to server path and then redirects to S3 Bucket path.

I have also tried the below code, but it's not working

Model.first.image.service_url

It throws error:

URI::InvalidURIError (bad URI(is not URI?): nil)
1

1 Answers

1
votes

Use image tag with following way to use direct S3 URL:

<%= image_tag Model.first.image.variant(resize_to_limit: [50, 50]).processed.service_url %>