Why Stackoverflow code to download file in ruby via http does not work -


i need download tar.gz file http repository. searched on stackoverflow , found several code snippets no 1 works. problem file created in local has 0 file size.

here code snippet used:

require 'open-uri' require 'uri' require 'fileutils'  class downloadmanager     def downloadurl(url, destination_folder)         url_obj = uri.parse(url)         basename=file.basename(url_obj.path)         fileutils::mkdir_p "#{destination_folder}"         file.open("#{destination_folder}/#{basename}", "w") |f|             io.copy_stream(open(url), f)         end     end      ... end  downloadmanager = downloadmanager.new downloadmanager.downloadurl("<my url>", "c:/cf/253.6.0") 

what's wrong code. why hangs when download starts , file size remain 0?


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -