July 23, 2014

How to Handle Gzipped Files in Ruby

Late last night, I was debugging the fact that the shared links are now stored compressed and realised the atom feed I had so carefully put together earlier was not working because ruby wasn't hip enough to recognise Gzip compression out of the box (to be fair, though, that would be a performance hit without much benefit. Especially given that solving the problem is cake:

require 'zlib'
Zlib::GzipReader.open("/path/to/compressed-file") {|gz|
   # do what you will here
}

No comments:

Post a Comment