def upload_folder_to_gcs()

in generate/util.py [0:0]


def upload_folder_to_gcs(bucket_name, local_folder, gcs_prefix=""):
    """Uploads a folder to the bucket recursively."""

    storage_client = storage.Client()
    bucket = storage_client.bucket(bucket_name)

    for path, dirs, files in os.walk(local_folder):
        # skip hidden files
        dirs[:] = [d for d in dirs if not d.startswith(".")]
        files = [f for f in files if not f.startswith(".")]
        for name in files:
            local_file = os.path.join(path, name)
            local_file_path = os.path.relpath(local_file, local_folder)
            blob_name = os.path.join(gcs_prefix, local_file_path)
            blob = bucket.blob(blob_name)
            blob.upload_from_filename(local_file)
        print(f"Files {','.join(files)} uploaded to gs://{bucket_name}/{gcs_prefix}")