Hi everyone, I'm just dabbling in Ruby and making little programs that
help me dive in.  However, I'm having some issues around net/http and
open-uri.

In Python, I made an imgur.com image downloader that basically scrapes
the screen for images and then uses urllib/urllib2 to download them.
Works flawlessly.

I've recreated the same program in Ruby, but it only works for about 35%
of the links it comes across.  The rest throw the following error when
it comes to actually downloading and saving the file:

C:/Ruby192/lib/ruby/1.9.1/open-uri.rb:35:in `initialize': Permission
denied - G:/downloads/images/ (Errno::EACCES)

Here's a couple code variations I've tried using:

url = URI.parse(fileURL)
http = Net::HTTP.start(url.host, url.port)
resp = http.request_get(url.path, "User-Agent"=> 'Mozilla/5.0')
open(fullPath + '/' + fileName, 'wb') do |file|
    file.write(resp.read_body)

OR:

resp = Net::HTTP.get_response(URI.parse(fileURL))
open(fullPath + '/' + fileName, 'wb') do |file|
    file.write(resp.body)


These links throwing an error are the same links that download fine and
work fine in Python writing to the same directory structure - and I
can't figure out what is wrong.

Someone suggested using the image_downloader gem, but it didn't work.  I
opened up the source for it and its basically doing the same thing I was
doing manually, so it figures it would fail.

Anybody know what's going on here? :(

Thank you in advance!

-- 
Posted via http://www.ruby-forum.com/.