Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
1.2 KiB

class CollectionResourcesService
def initialize
@storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["COLLECTION_RESOURCES_BUCKET"])
end
def get_file(file)
storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["COLLECTION_RESOURCES_BUCKET"])
url = "https://#{storage_service.configuration.bucket_name}.s3.amazonaws.com/#{file}"
uri = URI.parse(url)
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
request = Net::HTTP::Get.new(uri)
http.request(request)
end
return unless response.is_a?(Net::HTTPSuccess)
response.body
end
def get_file_metadata(file)
storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["COLLECTION_RESOURCES_BUCKET"])
url = "https://#{storage_service.configuration.bucket_name}.s3.amazonaws.com/#{file}"
uri = URI.parse(url)
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
http.request_head(uri)
end
return unless response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPRedirection)
response
end
end