# Download Zip File

**URL:** <https://www.ruby-forum.com/t/download-zip-file/130216>\
**Category:** Ruby\
**Created:** [February 26, 2008, 1:49pm UTC](https://www.ruby-forum.com/t/download-zip-file/130216 "2008-02-26T13:49:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@paulf](https://www.ruby-forum.com/u/paulf)\
**Post date:** [February 26, 2008, 1:49pm UTC](https://www.ruby-forum.com/t/download-zip-file/130216/1 "2008-02-26T13:49:59Z")

</div>

I have tried to use rio gem to download a zip file (in windows) but it  
results in a corrupt d/l. I think this is because binary mode is not  
available in rio.  
So I am now trying to use open-uri

require ‘open-uri’  
f = open (url)

f is of class tempfile. How do I save this temp file to disk?  
Does open-uri have a binary mode option, or is it the default?

Or is there a more elegant ruby way to d/l binary mode files ?

Thanks  
Paul F.

---

<div class="post-metadata">

**Author:** ![paulf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@paulf](https://www.ruby-forum.com/u/paulf)\
**Post date:** [February 26, 2008, 3:36pm UTC](https://www.ruby-forum.com/t/download-zip-file/130216/2 "2008-02-26T15:36:34Z")

</div>

I used the example at [http://snippets.dzone.com/posts/show/2469](http://snippets.dzone.com/posts/show/2469) to  
download some pictures, the “wb” is important, so that the file is  
opened in binary mode, otherwise you’ll end up with ascii mode and  
your file contains corrupted data.
