Shrine (vs Carrierwave)

Anyone used Shrine for uploads?

I’m really excited about this. I’ve just released Shrine, a new solution for handling file uploads in Ruby applications. It was heavily inspired by Refile, most notably its idea of backends. However, unlike Refile, it is designed primarily for upfront processing (as opposed to on-the-fly). It’s also inspired by CarrierWave’s idea of uploaders.

I want to try but it’s too difficult to use 2 different gems in one project
And I don’t have a pet project :stuck_out_tongue: (nor time)

2 Likes

What is shrinerb’s value-add?

Mostly, carrierwave just works for me, so I’m not really in the market, but I’m curious.

2 Likes

I’m not sure. I pinged @janko-m asking if he would come on and chime in :smiley:

1 Like

@kofno One of the biggest values of Shrine over other libraries like CarrierWave and Paperclip is the ability to make file uploads completely asynchronous. Shrine has built-in reliable support for backgrounding processing, uploading and deleting. Using background jobs for managing files is important for good user experience (because the user doesn’t need to wait), and for application throughput (slow things are taken out of the request). CarrierWave and Paperclip both have gems that try to add backgrounding support, but they do a poor job of it.

Another advantage of Shrine is that it stores location & metadata of the attachment (each version separately) in a single column as JSON. It can also determine actual MIME type (without all the fuss Paperclip currently has) and image dimensions, and it’s easy to extract your own metadata. Benefit of storing full location for each file is that changing how you generate the location doesn’t invalidate existing files (unlike with CarrierWave and Paperclip).

Shrine is the only file upload library which has support for logging. It logs processing, uploading and deleting separately. This makes things much easier to debug (you have all necessary context) and allows you to measure performance (durations for each actions are printed).

Finally, Shrine focuses a lot on security. For example, CarrierWave does processing before validation, which is very insecure, because if you limit the maximum filesize, that won’t yet take effect during processing, so people can still make you process arbitrarily large files (CarrierWave team closed this issue without fixing it). With Shrine this is not a problem.

There are many more advantages, but I already wrote a lot :slight_smile: . See the introductory post for more.

@PikachuEXE If you’re interested, I wrote guides to help CarrierWave (and Paperclip and Refile) users migrate an existing app to Shrine.

2 Likes

Thanks, let me take a look later