INNER CODE UNIT · Python

upload_to_gcs_format_async

openfoodfacts/openfoodfacts-ai · category-detection/main.py:327

async def upload_to_gcs_format_async(
    record: dict[str, Any],
    bucket_name: str,
    session: aiohttp.ClientSession,
    base_image_dir: Path | None = None,
) -> dict[str, Any] | None:
    parts = record["request"]["contents"][0]["parts"]
    record_key = record["key"]
    for part in parts:
        if "file_data" in part:
            file_uri = part["file_data"]["file_uri"]
            image_blob_name = f"dataset-images/{record_key}/{Path(file_uri).name}"
            # Download the image from the URL
            try:
                await upload_to_gcs(
                    image_url=file_uri,
                    bucket_name=bucket_name,
                    blob_name=image_blob_name,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…