Reputation: 2343
Let's say I got a project which has something like a media pool. Basically I wanna be able to upload whatever file you could upload (images, videos, pdf, etc.).
I was thinking about going with refile since it supports on-the-fly-processing of images which is nice since there is going to be an image api that should let the user request the image in whatever size he needs.
BUT, how would I handle pdf uploads or video uploads(even video processing)?
Is there maybe a better alternative to refile?
Thank you very much!
Upvotes: 0
Views: 267
Reputation: 9305
First of all, file attachment libraries can generally upload any type of file. Most popular are Paperclip and CarrierWave. They give you the ability to process on upload, which is suitable for videos. However, they don't allow you to process on-the-fly.
Dragonfly and Refile are, on the other hand, designed for on-the-fly processing. An upside of Refile is its support for direct uploads. One downside of Refile is that you have to serve all files through its Rack app, so if you have videos uploaded on S3 which you won't process, you still need to pay the performance penalty on first non-cached render. An upside of Dragonfly is that it has much more advanced on-the-fly processing support, and it also allows you to process on upload.
Lastly, we come to Shrine. Shrine was designed for processing on upload, and it's the only library with native support for background jobs, which is especially useful for longer processing like video transcoding. Shrine also has a Transloadit integration, if you want to delegate processing to a 3rd-party service. But you can also get on-the-fly processing with Shrine, using services like Cloudinary or even hooking up Dragonfly (see this post). Shrine has support for direct uploads, like Refile. Some of the other notable features include: metadata support, logging, flexible file validation, resumable uploads, better security and other.
Since Shrine arguably has most features and flexibility than any other file attachment library, I would recommend going for it.
Upvotes: 1