class Multiwoven::Integrations::Source::AmazonS3::Client
def download_file_to_local(bucket_name, file_path, sync_id)
def download_file_to_local(bucket_name, file_path, sync_id) download_path = ENV["FILE_DOWNLOAD_PATH"] file = if download_path File.join(download_path, "syncs", sync_id, File.basename(file_path)) else Tempfile.new(["s3_file", "syncs", sync_id, File.extname(file_path)]).path end object = @s3_resource.bucket(bucket_name).object(file_path) object.get(response_target: file) [RecordMessage.new( data: { local_path: file, file_name: File.basename(file_path), file_path: file_path, size: object.content_length, file_type: File.extname(file_path).sub(".", ""), modified_date: object.last_modified.to_s, created_date: object.last_modified.to_s }, emitted_at: Time.now.to_i ).to_multiwoven_message] rescue Aws::S3::Errors::NoSuchKey raise "File not found: #{file_path}" end