class Multiwoven::Integrations::Source::AmazonS3::Client

def handle_unstructured_data(sync_config)

def handle_unstructured_data(sync_config)
  connection_config = sync_config.source.connection_specification.with_indifferent_access
  bucket_name = connection_config[:bucket]
  command = sync_config.model.query.strip
  create_s3_connection(connection_config)
  case command
  when LIST_FILES_CMD
    list_files_in_folder(bucket_name, connection_config[:path] || "")
  when /^#{DOWNLOAD_FILE_CMD}\s+(.+)$/
    # Extract the file path and remove surrounding quotes if present
    file_path = ::Regexp.last_match(1).strip
    file_path = file_path.gsub(/^["']|["']$/, "") # Remove leading/trailing quotes
    download_file_to_local(bucket_name, file_path, sync_config.sync_id)
  else
    raise "Invalid command. Supported commands: #{LIST_FILES_CMD}, #{DOWNLOAD_FILE_CMD} <file_path>"
  end
end