add download utils

This commit is contained in:
Pete Matsyburka
2024-09-07 01:30:34 +03:00
committed by Oleksandr Turchyn
parent 71b8cc7172
commit 5a1efd0e27
5 changed files with 37 additions and 22 deletions
+1 -13
View File
@@ -11,7 +11,6 @@ module Submitters
UnknownFieldName = Class.new(BaseError)
InvalidDefaultValue = Class.new(BaseError)
UnknownSubmitterName = Class.new(BaseError)
UnableToDownload = Class.new(BaseError)
TRUE_VALUES = ['1', 'true', true, 'TRUE', 'True', 'yes', 'YES', 'Yes'].freeze
FALSE_VALUES = ['0', 'false', false, 'FALSE', 'False', 'no', 'NO', 'No'].freeze
@@ -185,12 +184,7 @@ module Submitters
return blob if blob
uri = Addressable::URI.parse(url)
resp = conn.get(uri.display_uri.to_s)
raise UnableToDownload, "Error loading: #{uri.display_uri}" if resp.status >= 400
data = resp.body
data = DownloadUtils.call(url).body
checksum = Digest::MD5.base64digest(data)
@@ -215,11 +209,5 @@ module Submitters
nil
end
def conn
Faraday.new do |faraday|
faraday.response :follow_redirects
end
end
end
end