[ActiveStorage] vs Paperclip

Hello everybody,

I’m in the process of porting a big SaaS platform from Rails 4.2 to Rails 5.2. Everything has been quite smooth until we discovered that the paperclip gem is no longer maintained; the author recommends moving to ActiveStorage. Unfortunately we found some ActiveStorage features to be a step back compared to Paperclip for our specific use case:

  1. Attachments are not supposed to be accessed directly, but through a rails controller, which implements a redirect. The redirect URL is temporary.

The benefits of this approach are clear and very important in some contexts, but there are some drawbacks as well, especially for public facing sites:

  • I think this behaviour could be marked as a problem by SEO analyzers, which usually require to minimize redirects

  • it puts extra workload on clients, which need an extra HTTP request for each attachment

  • the extra request is not made to a CDN, but to the central server, further increasing latency

  • extra workload is put on the Rails stack increasing hosting costs

In some blog post I found the suggestion to use the service_url() method directly. This would have 2 drawbacks:

  • the URL is temporary, thus it cannot be cached

  • the URL is not SEO friendly

  1. In the case of S3 there is no way to specify a folder where the attachment will be stored, the S3 bucket is supposed to be completely taken over by ActiveStorage. I think this is a good strategy in most cases, but if you are implementing a SaaS service using the Apartment gem like us, it really is a big issue. Basically in our system each client has a separate copy of all application tables, and with paperclip we easily managed to share the same bucket using different folders.

Now we would be supposed to create a different bucket for each client, which further require us to create a cloudfront instance for each of them, increasing management efforts and costs.

Please let me know if I misunderstood something or if you have any plan to address these issues.

Thank you guys, keep up the good work!

Diego

Stumbled across the same problem some time ago but, looking on the net, I didn’t find a consistent solution. It might be interesting to see if there is a direct access mode that circumvents the redirect (point 1), for the advantages listed above.

I would like to listen to plans about no. 3 – folders support in ActiveStorage S3 implementation.

Of course, one can mitigate it in multiple ways but most of them defeat the purpose of using AS in the first place.

IDK if you’ve seen this but direct uploads, which can be handled by front-end anyway, ARE implemented - this gives me hope folders might be somewhere soon on the roadmap as they seem a bit more fundamental.

There’s no road map for improvements to Active Storage at the moment. If there are features you’d like to see, Please Do Investigate, as we say. A pull request with the proposed solution is the best way to go. Thanks for getting involved!