Categories
rails

Rails Paperclip Image Storage – Redux

Paperclip is probably the most popular and feature-rich solution for integrating file uploading and management into an application. It’s an easy file attachment library for Active Record. The main features of Paperclip include basic file uploading, validations and callbacks, post-processing (which includes generating thumbnails) and finally storing the images in AWS S3/ Google Cloud / Microsoft Azure/ Dropbox, etc.

Paperclip began in August of 2007 by thoughtbot. It was a pet project of Jon Yurek, with the first commit in April of 2008 by Mark Van Holstyn. Since then, it took off, and they defined it as open source for an era. Later, in 2017 they decided to deprecate Paperclip, and that marked a kick start to kt-paperclip.

An important advantage of Paperclip over other alternatives such as Active Storage is that it allows for lot more customisation. Further more it doesn’t uses STI, see some better data model design patterns in newer frameworks. Paperclip generates the image variants at the time of upload, and so unlike Active Storage it doesn’t requires requests to Rails server to check if the image variant exists or needs to be generated.

kt-paperclip is redux of the original paperclip, and is constantly being updated and maintained. The first commit to kt-paperclip came in Nov 2019, where we promised to support and maintain paperclip. Later, we replaced mocha and bourne with rspec mocks, updated it so that post process hooks are not called if validation fails. Now, you can use kt-paperclip with rails version 5 and higher, and it supports newer Ruby Versions as well.

We are very happy to see the total number of downloads increasing significantly over the last few months. Officially thoughtbot has our GitHub link updated on their readme. If you’d like to contribute a feature or bugfix: Thanks! Feel free to create pull requests, open issues. Thanks to all the contributors.