From: Robert Klemme Date: 2008-09-16T03:57:47+09:00 Subject: Re: how to stream or write data into a tar.gz file as if the data were from files? On 15.09.2008 20:35, bwv549 wrote: > I have a gazillion little files in memory (each is really just a chunk > of data, but it represents what needs to be a single file) and I need > to throw them all into a .tar.gz archive. In this case, it must be > in .tar.gz format and it must unzip into actual files--although I pity > the fellow that actually has to unzip this monstrosity. > 3. Not portable, but fast: > stream information into tar/gzip to create the archive (without > ever first writing out files) > > I've been looking around on this and the closest I've come is this: > tar cvf - some_directory | gzip - > some_directory.tar.gz > > Note that this would still require me to write the files to a > directory (which must be avoided at all costs), but at least the > problem now is how to write data into a tar file. I've been googling > and still haven't turned up anything yet. So why then do you say "without ever first writing out files"? I'd say #3 (the original formulation) is the one to go. Googling for "ruby tar" quickly turned up this: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/32588 And there is zlib which allows to read and write GZip streams. So, if ruby-tar allows to write into any stream you got your solution. Kind regards robert