class BulkUpload::Downloader
attr_reader :bulk_upload
delegate :path, to: :file
def initialize(bulk_upload:)
@bulk_upload = bulk_upload
end
def call
download
def delete_local_file!
file.unlink
private
def download
io = storage_service.get_file_io(bulk_upload.identifier)
file.write(io.read)
io.close
file.close
def file
@file ||= Tempfile.new
def storage_service
@storage_service ||= if FeatureToggle.upload_enabled?
s3_storage_service
else
local_disk_storage_service
def s3_storage_service
Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
def local_disk_storage_service
Storage::LocalDiskService.new