As an extension on my previous image problem I can’t even successfully
download images from a URL location. I though tthe following simple GET
request along with writing the result to a file would work but it
mangles
the image and makes it unreadable.
Net::HTTP.start(“www.example.com”) do |http|
resp = http.get(“/images/logo.gif”)
outfile = open(“C:/logo.gif”, “w”)
outfile.write(resp.body)
outfile.close
end
Have I done something wrong here? Can anyone see what I’m doing wrong?
Sorry for being a pain but I’ve looked in the mailing list and various
source files but none seem to be shedding any light so I’d be very
grateful
for your input.
This is done in order to ensure that if there’s an exception after
you open the file (ferinstance, writing when the disk is full, or in
a place you don’t have write permissions), that the file is still
closed. You could do the exception handling yourself, of course, but
this is a convenient concise way of doing things.
As an extension on my previous image problem I can’t even successfully
download images from a URL location. I though tthe following simple GET
request along with writing the result to a file would work but it
mangles
the image and makes it unreadable.
Net::HTTP.start(“www.example.com”) do |http|
resp = http.get(“/images/logo.gif”)
outfile = open(“C:/logo.gif”, “w”)
outfile.write(resp.body)
outfile.close
end
Have I done something wrong here? Can anyone see what I’m doing wrong?
Sorry for being a pain but I’ve looked in the mailing list and various
source files but none seem to be shedding any light so I’d be very
grateful
for your input.
All the best.
Doug
Hi All,
Get all images from given URL
Desktop Application from jazzez
Kindly go through below link and download the EXE file.
Install in Windows machine and enjoy with impressed images
Regards,
P.Raveendran
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.