Method: FileDownloader::Service#execute

Defined in:
lib/file_downloader/service.rb

#executeObject



16
17
18
19
20
21
22
23
24
# File 'lib/file_downloader/service.rb', line 16

def execute
  uri = URI.parse(url)
  http = Net::HTTP.new(uri.host, uri.port)

  content_length = fetch_content_length(http, uri)
  raise NoResponseBodyError if content_length.to_i.zero?
  download_file(http, uri, content_length)
  filepath
end