Thiago
Thiago

Reputation: 2258

Instantiating File from a remote url in a rails controller

Is there a way to have something like this:

File.new('http://hostname/myfile.zip')

inside a controller?

Upvotes: 0

Views: 1609

Answers (1)

vise
vise

Reputation: 13383

require 'open-uri'
file = open(URI.parse('http://www.google.com/intl/en_ALL/images/logo2.gif'))
puts file.size
=> 8558

Upvotes: 3

Related Questions