Web apps often produce files such as images, videos or documents. For a long time it was standard to put those files into the filesystem – but as we mentioned in a recent post – today that is considered a bad practice. Instead we recommend using OpenStack Swift, a highly scalable solution that can serve up to hundreds of petabytes. What’s more is that Swift is redundant, allowing the service to survive the outage of one or multiple servers.
In the post I mentioned earlier, we looked at the Paperclip gem, and combined it with Swift to produce files. In this post we’ll look at Carrierwave. The Carrierwave gem provides a simple and extremely flexible way to upload files from Ruby applications. It works well with Rack based web applications, such as Ruby on Rails.
Carrierwave + Swift demo application
We wrote a small application that demonstrates how Rails 3.2.13, Carrierwave, a9s Swift Service and PostgreSQL work together. You can find the example app on GitHub. This application is an adaptation of n0ne’s Rails-Carrierwave-jQuery-File-Upload application. You can use this application to do a test run on anyines.com. read more