sumitasok
9/17/2013 - 5:23 AM

active_dispatch_http_upload_file_emulation with Net::HTTP::Persistent to connect and pull in file over http.

active_dispatch_http_upload_file_emulation with Net::HTTP::Persistent to connect and pull in file over http.

uri = URI 'http://1.bp.blogspot.com/-1bMuoR67oxo/TwufbSRhrrI/AAAAAAAAALE/uDGLAaynSJ0/s400/Profiles+in+Search+2.png'
http = Net::HTTP::Persistent.new 'my_app_name'
response = http.request uri

data = response.body

file_binary_expected = open('http://milushov.ru/bg.jpg').read
file = ActionDispatch::Http::UploadedFile.new(:tempfile => file_binary_expected,
        :filename => File.basename(file_binary_expected))