Remote files?

I need to read the contents of 2 files on a remote webserver, for
example: 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?

On Tue, Mar 25, 2008 at 11:30 AM, [email protected] 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

On Tue, Mar 25, 2008 at 11:30 AM, [email protected] 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
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.

On 25 Mar., 13:53, Thomas W. [email protected] wrote:

On Tue, Mar 25, 2008 at 11:30 AM, [email protected] 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 :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs