A great answer here explains how, in Ruby, to download a file without loading it into memory:
https://stackoverflow.com/a/29743394/4852737
require 'open-uri'
download = open('http://example.com/image.png')
IO.copy_stream(download, '~/image.png')
How would I verify that the IO.copy_stream call to download the file was actually successful — meaning that the downloaded file is the exact same file I intended to download, not a half downloaded corrupt file? The documentation says that IO.copy_stream returns the number of bytes that it copied, but how can I know the number of bytes expected when I have not downloaded the file yet?