I am trying to upload an image to a google cloud storage bucket using gcloud-aio-storage client library. I want the image to be accessible publically. I have gone through the documentation but couldn't find an option to pass predefined_acl or acl in the upload method. I have written the following code :
import asyncio
from gcloud.aio.auth import Token
from gcloud.aio.storage import Storage
async def upload_image(bucket_name, image_name, data):
SCOPES = ["https://www.googleapis.com/auth/devstorage.read_write"]
token = Token(service_file="key.json", scopes=SCOPES)
async with Storage(token=token) as client:
image = await client.upload(bucket=bucket_name, object_name=image_name, file_data=data)
await token.close()
return image["name"]
I have also tried the following piece of code as suggested by other resources on the internet but it didn't work:
image = await client.upload(bucket=bucket_name, object_name=image_name, file_data=data, acl='publicRead')
I am using the following version of gcloud-aio-storage :
Name: gcloud-aio-storage
Version: 9.2.0