class Multiwoven::Integrations::Destination::AmazonS3::Client

def upload_csv_content(sync_config, records)

def upload_csv_content(sync_config, records)
  connection_config = sync_config.destination.connection_specification.with_indifferent_access
  conn = create_connection(connection_config)
  file_name = generate_local_file_name(connection_config)
  csv_content = generate_csv_content(records)
  begin
    @args = ["create", connection_config[:bucket_name], "#{connection_config[:file_path]}#{file_name}", csv_content]
    @response = conn.put_object(
      bucket: connection_config[:bucket_name],
      key: "#{connection_config[:file_path]}#{file_name}",
      body: csv_content
    )
    write_success = records.size
  rescue StandardError => e
    handle_exception(e, {
                       context: "AMAZONS3:RECORD:WRITE:EXCEPTION",
                       type: "error",
                       sync_id: sync_config.sync_id,
                       sync_run_id: sync_config.sync_run_id
                     })
    write_success = 0
  end
  write_success
end