Search code examples
ruby-on-railsrails-activestorage

rails blob path vs service url


I have a rails application that has Active Storage and stores objects in Amazon S3.

So far, I have been using rails_blob_path but then I discovered service_url.

rails_blob_path returns an URL to the rails application and rails redirects you to S3.

service_url directly returns the URL to the S3 object.

I wonder what could be the advantage(s) of using one or the other? When is it better?


Solution

  • Check out the documentation on service_url here: https://api.rubyonrails.org/classes/ActiveStorage/Variant.html#method-i-service_url

    Basically, there's usually not a good reason to provide your users with the service_url.