How can I download a file located on a remote website (a download link is available or an address to an actual file on the remote server) to the server running the rails application? The file needs to be stored in a specific folder in the server file system.
Asked
Active
Viewed 708 times
0
-
It depends, would you like the users to submit the remote file's urls? – dombesz Jan 08 '12 at 15:07
-
It is a fixed location, I have it as a string – Itay k Jan 08 '12 at 17:29
-
Please see this thread: http://stackoverflow.com/questions/2263540/how-do-i-download-a-binary-file-over-http-using-ruby – dombesz Jan 08 '12 at 17:39
2 Answers
2
Let's do it step by step:
Use the carrierwave
in your Gemfile:
gem 'carrierwave'
in your view
<%= f.text_field :remote_image_url %>
in your model
attr_accessible :remote_image_url
More detail you can check Ryan's railscast#253 CarrierWave File Uploads

Kuo Jimmy
- 801
- 5
- 13
0
You could use Carrierwave as an upload plugin and use its Uploading files from a remote location feature to upload something via a URL.

Tim Brandes
- 2,103
- 15
- 14