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:
- 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
- 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