title: Rails API ActiveStorage: Get Public URL to display image from AWS S3 Bucket?
body: <p>I have a Rails 5.2 API set up and have followed the documentation on how to attach images to a model object - that's all working fine. The problem I'm having is I want to return in a JSON object the attachment's public URL so that I can use that URL as the source in an <code>&lt;img src...</code> in my React front end. Is there a way to return the actual URL from the AWS S3 bucket, where the image would show up if clicked on?</p>
  
  <p>Right now, I've tried <code>rails_blob_path</code>, <code>service_url</code>, and I do get URLs in return, but neither of them actually render the image the way I'd hope. Any workarounds to this?</p>
  
  <p>Again, just want the attachment's actual public URL from s3 so I can plug it in to the <code>src</code> attribute inside an <code>&lt;img&gt;</code> and have it display. Thanks.</p>
  
  <p>My development.rb file configures <code>config.active_stoarge.service = :amazon</code>.</p>
  
  <p>My storage.yml file has amazon configured like so:
  <code>amazon:
    service: S3
    access_key_id: &lt;%= Rails.application.secrets.amazon[:access_key] %&gt;
    secret_access_key: &lt;%= Rails.application.secrets.amazon[:secret_key] %&gt;
    region: us-east-2
    bucket: my_bucket_name_here
  </code></p>
  
  <p>ActiveStorage 5.2.2</p>
  
  <p>Rails 5.2.2</p>