M
Marcelo Paniagua
Hi there!
I'm starting to use Net::Http.
I'm fetching an image from a page with the following code
Net::HTTP.start(address) do |http|
#req = Net::HTTP::Get.new('http://a page')
req = Net::HTTP::Get.new('http://a page/a_image.JPG')
req.basic_auth 'user', 'password'
response = http.request(req)
file = File.new('file.jpg',"w")
file.write(response.body)
file.close
the problem is that the file created has additional info and the image
can't be readed.. Any idea what I'm doing wrong?
I'm starting to use Net::Http.
I'm fetching an image from a page with the following code
Net::HTTP.start(address) do |http|
#req = Net::HTTP::Get.new('http://a page')
req = Net::HTTP::Get.new('http://a page/a_image.JPG')
req.basic_auth 'user', 'password'
response = http.request(req)
file = File.new('file.jpg',"w")
file.write(response.body)
file.close
the problem is that the file created has additional info and the image
can't be readed.. Any idea what I'm doing wrong?