# Creating a ZIP archive purely in memory?

**URL:** <https://www.ruby-forum.com/t/creating-a-zip-archive-purely-in-memory/48397>\
**Category:** Rails\
**Created:** [November 17, 2005, 1:08am UTC](https://www.ruby-forum.com/t/creating-a-zip-archive-purely-in-memory/48397 "2005-11-17T01:08:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@michael](https://www.ruby-forum.com/u/michael)\
**Post date:** [November 17, 2005, 1:08am UTC](https://www.ruby-forum.com/t/creating-a-zip-archive-purely-in-memory/48397/1 "2005-11-17T01:08:47Z")

</div>

Has someone devised a way to create a ZIP archive purely in memory? I  
know of rubyzip, but apparently it can only create an archive as a  
file. That’s not too bad, but if I can I’d prefer to do this in memory.

Michael

–  
Michael S. They tell you that the darkness  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) Is a blessing in disguise  
[Michael Schürig | Sentenced to making sense](http://www.schuerig.de/michael/) --Janis Ian, From Me To You

---

<div class="post-metadata">

**Author:** ![michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@michael](https://www.ruby-forum.com/u/michael)\
**Post date:** [November 17, 2005, 1:26am UTC](https://www.ruby-forum.com/t/creating-a-zip-archive-purely-in-memory/48397/2 "2005-11-17T01:26:53Z")

</div>

Out of curiosity, why?

If you want to work around it, you can mount a ramdisk and zip to a  
file in that… or perhaps look at FuseFS  
([http://rubyforge.org/projects/fusefs/](http://rubyforge.org/projects/fusefs/)) if you want to roll your  
own…

Alternatively you could just use ZLib, but I assume you want zip for a  
reason…

Cheers!

-DF

---

<div class="post-metadata">

**Author:** ![michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@michael](https://www.ruby-forum.com/u/michael)\
**Post date:** [November 17, 2005, 1:32am UTC](https://www.ruby-forum.com/t/creating-a-zip-archive-purely-in-memory/48397/3 "2005-11-17T01:32:54Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Nov 16, 2005, at 4:25 PM, David F. wrote:

> On 11/17/05, Michael S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Has someone devised a way to create a ZIP archive purely in memory? I  
> > know of rubyzip, but apparently it can only create an archive as a  
> > file. That’s not too bad, but if I can I’d prefer to do this in  
> > memory.  
> > Out of curiosity, why?

I guess he’s dynamically generating a zipfile for his users to download.

e.g. download all posts from the past month.

jeremy  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDe88TAQHALep9HFYRAnAqAKCXdX2GHMP3zhHJIvaoAJRwESMRDQCghqHF  
jtogVZGjstVd2rQLiatrEOk=  
=cafG  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@michael](https://www.ruby-forum.com/u/michael)\
**Post date:** [November 17, 2005, 2:18am UTC](https://www.ruby-forum.com/t/creating-a-zip-archive-purely-in-memory/48397/4 "2005-11-17T02:18:05Z")

</div>

On Thursday 17 November 2005 01:30, Jeremy K. wrote:

> download.  
> Exactly. Doing this in memory and then send\_data’ing would just be more  
> convenient than creating a temporary file and using send\_file on it.

Michael

–  
Michael S. There is no matrix,  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) only reality.  
[Michael Schürig | Sentenced to making sense](http://www.schuerig.de/michael/) --Lawrence Fishburn

---

<div class="post-metadata">

**Author:** ![michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@michael](https://www.ruby-forum.com/u/michael)\
**Post date:** [December 12, 2006, 9:51am UTC](https://www.ruby-forum.com/t/creating-a-zip-archive-purely-in-memory/48397/5 "2006-12-12T09:51:57Z")

</div>

Did anyone ever come up with a way of doing this (other than using  
chilkats zip library)?

Thanks

P

---

<div class="post-metadata">

**Author:** ![michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@michael](https://www.ruby-forum.com/u/michael)\
**Post date:** [December 12, 2006, 1:47pm UTC](https://www.ruby-forum.com/t/creating-a-zip-archive-purely-in-memory/48397/6 "2006-12-12T13:47:57Z")

</div>

[http://www.rubyonrailsblog.com/articles/2006/11/07/zipping-and-unzipping-multiple-directories-using-rubyzip](http://www.rubyonrailsblog.com/articles/2006/11/07/zipping-and-unzipping-multiple-directories-using-rubyzip)

what about that ?
