Search code examples
rubyapiruby-on-rails-4

Ruby on Rails - get file from URL


I'm Using Amazon Ads API which giving me a URL as a response... Opening that URL in browser, giving me a file that I need... Problem is I Don't know how to get the file from the URL in ruby... can anyone help me???

Thanks


Solution

  • require 'open-uri'
    contents = URI.open("https://hello.mdominiak.com").read
    

    Documentation: https://ruby-doc.org/stdlib-3.1.2/libdoc/open-uri/rdoc/OpenURI.html