Ashish
Ashish

Reputation: 5791

Read file from one remote location and upload it to another remote location in ruby

Suppose I have an URL http://mydomain.com/abc.mp3 from where I want to copy the audio file and want to upload it on another URL http://another_doamin.com/abc.mp3

Anyone can suggest me to do this in ruby.

Thanks in advance.

Upvotes: 0

Views: 457

Answers (1)

Miki
Miki

Reputation: 7188

There are many options, depending a lot on what are the capabilities of your applications (servers). You might want to be a little more precise in your question. Here are some that spring to my mind when thinking about "reading file from one location and uploading it to another":

  1. Use FTP. Either directly from one domain to another (if one of them has FTP server and you have shell access to the other), or through a third machine (download with http and upload with ftp, assuming that another domain has FTP server). Here is some documentation you may find useful, it includes an example. This is probably the simplest and most straightforward option.
  2. Submit the file through HTML form, assuming that something (like Rails app or even PHP script) can handle such request at another domain. You can do that with HTTP, as documented here, with examples, and answered in this thread.
  3. Use forwarding from an address in another domain to an address in my domain, assuming you have control over app running at another domain. This is more Rails than Ruby. It will not make your file transferred from one domain to another, instead it will redirect calls from one address to the other.
  4. Obtain (with 1., 2., wget...) the file from my domain while generating page on another domain, assuming as in 3. Once again, this is more Rails than pure Ruby. This will obtain a copy of a file from one domain to another whenever requested.

Upvotes: 1

Related Questions