INNER CODE UNIT · Python
upload_bytes_to_gcs
rohitg00/awesome-ai-apps · multimodal-apps/gemini-veo-sketch2video/app.py:57
def upload_bytes_to_gcs(image_bytes: bytes, bucket_name: str, destination_blob_name: str) -> str:
"""Uploads image bytes to GCS and returns the GCS URI."""
if not gcs_client:
raise ConnectionError("GCS client is not initialized.")
bucket = gcs_client.bucket(bucket_name)
blob = bucket.blob(destination_blob_name)
blob.upload_from_string(image_bytes, content_type='image/png')
gcs_uri = f"gs://{bucket_name}/{destination_blob_name}"
print(f"Image successfully uploaded to {gcs_uri}")
return gcs_uri
# --- Main Routes ---
@app.route('/')
def index():
"""Renders the main HTML page."""