# Remote files?

**URL:** <https://www.ruby-forum.com/t/remote-files/132858>\
**Category:** Ruby\
**Created:** [March 25, 2008, 11:31am UTC](https://www.ruby-forum.com/t/remote-files/132858 "2008-03-25T11:31:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 25, 2008, 11:31am UTC](https://www.ruby-forum.com/t/remote-files/132858/1 "2008-03-25T11:31:14Z")

</div>

I need to read the contents of 2 files on a remote webserver, for  
example: [http://www.domain.com/box/text.txt](http://www.domain.com/box/text.txt)

The first file is a plain-text file and the other is a binary file  
(photo).

Text file:  
I need to read the text and keep in memory

Binary file:  
Basically I just need to move the contents to my own server and store  
it in a new file.

Can anyone send me on the right track?

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 25, 2008, 12:17pm UTC](https://www.ruby-forum.com/t/remote-files/132858/2 "2008-03-25T12:17:25Z")

</div>

On Tue, Mar 25, 2008 at 11:30 AM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Basically I just need to move the contents to my own server and store  
> it in a new file.
> 
> Can anyone send me on the right track?

open-uri, net/http

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 25, 2008, 1:54pm UTC](https://www.ruby-forum.com/t/remote-files/132858/3 "2008-03-25T13:54:22Z")

</div>

On Tue, Mar 25, 2008 at 11:30 AM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The first file is a plain-text file and the other is a binary file  
> (photo).

Take a look at  
[http://www.rubynoob.com/articles/2006/8/21/how-to-download-files-with-a-ruby-script](http://www.rubynoob.com/articles/2006/8/21/how-to-download-files-with-a-ruby-script)  
Notice “wb” in _open(“fun.jpg”, “wb”)_, it is important, when you  
download images on windows platforms otherwise it will open them in  
ASCII mode.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 25, 2008, 4:06pm UTC](https://www.ruby-forum.com/t/remote-files/132858/4 "2008-03-25T16:06:58Z")

</div>

On 25 Mar., 13:53, Thomas W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Tue, Mar 25, 2008 at 11:30 AM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > The first file is a plain-text file and the other is a binary file  
> > (photo).
> 
> Take a look athttp://www.rubynoob.com/articles/2006/8/21/how-to-download-files-with…  
> Notice “wb” in _open(“fun.jpg”, “wb”)_, it is important, when you  
> download images on windows platforms otherwise it will open them in  
> ASCII mode.

Hi,

thanks a lot for the answers. It works 🙂
