Unzipping a file

Hi !

I’m attempting to write a simple gallery in Rails. The thing is I’d like
to
be able to upload a lot of pictures at once with a zip file.

I’ve so far managed to upload the zip file (containing pictures) to the
server. But how do I unzip the file to have access to the pictures ? I
haven’t been able to understand how to use Zlib to do this.

Any tips or ideas welcome, especially if you have a better way of
accomplishing what I’d like to do…

Best regards,

David S.

http://rubyzip.sourceforge.net/
gem install rubyzip

Some example I found:

OUTDIR=“out”
Zip::ZipFile::open(“all.zip”) { |zf|
zf.each { |e|
fpath = File.join(OUTDIR, e.name)
FileUtils.mkdir_p(File.dirname(fpath))
zf.extract(e, fpath)
}
}

Software that uses rubyzip so you can look at examples are amongst
other Mephisto
http://svn.techno-weenie.net/projects/mephisto/

On 8/3/06, David S. [email protected] wrote:

accomplishing what I’d like to do…