Generating ZIP file archives via Ruby on Rails
Today I was presented with a challenge. In a project I’ve been working on (to be announced soon) - the Matt Sommers Digital Archive, there are musical artists, with many albums, which have multiple tracks. In the app, the tracks are uploaded via a form, and are processed using attachment_fu. What we needed was a way to generate a zip file of an entire album’s mp3’s, with the ability to re-generate it if any of the tracks change, and be able to present a link to make the entire album downloadable. At first, it sounded a little hard to do, but once I found out there was something called rubyzip, it became easy as cake. Here’s how I did it. (Hat tip to the author of this post for helping make it even easier for me.)
(more…)