# Unzipping a file

**URL:** <https://www.ruby-forum.com/t/unzipping-a-file/101289>\
**Category:** Rails\
**Created:** [August 4, 2006, 2:41am UTC](https://www.ruby-forum.com/t/unzipping-a-file/101289 "2006-08-04T02:41:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [August 4, 2006, 2:41am UTC](https://www.ruby-forum.com/t/unzipping-a-file/101289/1 "2006-08-04T02:41:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [August 4, 2006, 9:47am UTC](https://www.ruby-forum.com/t/unzipping-a-file/101289/2 "2006-08-04T09:47:09Z")

</div>

[http://rubyzip.sourceforge.net/](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/](http://svn.techno-weenie.net/projects/mephisto/)

On 8/3/06, David S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> accomplishing what I’d like to do…

–
