0

With Rails 6, I need to replace Paperclip, but I can't find any substitutions that actually easily replicate it.

Specifically, the file structure paperclip used:

:model/:attachmant_field/000/000/000/:identifier/:style/:original_file_name

Over the last decade we have built several tools that rely on that structure (or something similar) and in addition our users expect that after uploading an image, they can reference the styles with the same file name and a permanent url (not a randomly generated name like ActiveStorage and Shrine does) and change the "style" component in the url to a different one in their html.

I've spent several days both on Shrine and ActiveStorage working to get the file structure and naming to work on and keep failing, as despite being "natural replacements" they don't actually handle things in the same way.

Our end system is on Amazon S3, though integrating with that hasn't been the issue, just the file system.

Thanks for your help, it's been really frustrating having to remove something that works great when there seems to be nothing that actually replaces it, if you want/need things done in the same way. I'd rather not have to start rewriting all of tools that we developed and resetting our customers expectations to work with a new structure.

Thanks so much.

Jason Logsdon
  • 507
  • 5
  • 19
  • 1
    Has paperclip stopped working? (I know it has been deprecated). Alternatively, there is a fork of it here https://github.com/kreeti/kt-paperclip I have no idea how good that is though – Eyeslandic Nov 26 '21 at 16:29
  • @Eyeslandic, nice, I'll check out the fork. And yeah, the original doesn't load anymore in Rails 6+ – Jason Logsdon Nov 27 '21 at 14:03

1 Answers1

0

Have you tried Carrierwave? You can specify any storage path and build it dynamically using model name (model.class.to_s.underscore), attachment field (mounted_as), model id (model.id). The original file name is also available as original_filename.

Matt
  • 5,328
  • 2
  • 30
  • 43