Zipfile download through CURL to an actual Zip-file in your file structure Zipfile download through CURL to an actual Zip-file in your file structure curl curl

Zipfile download through CURL to an actual Zip-file in your file structure


I am using ruby 2.0

and my code is:

curl = Curl::Easy.new('http://somepage.cz/index.html')curl.on_body do |d|  f = File.open('output_file.html', 'w') {|f| f.write(d)}endcurl.perform

I had to change File.new to File.open without this it didn't worked.Moving curl.perfom on the end does helped me.


You're adding the on_body event after calling perform, which transfers the body. If you move the event declaration to before the perform call, this should work.