I am using django-storages and google-cloud-storage backend.
what I currently have is the following.
from django.conf import settings
from storages.backends.gcloud import GoogleCloudStorage
from storages.utils import clean_name
from django.conf import settings
class PublicImageUploadStorage(GoogleCloudStorage):
bucket_name = settings.IMAGES_BUCKET_NAME or None
file_overwrite = settings.IMAGES_OVERWRITE or True
def make_public(self, name):
name = self._normalize_name(clean_name(name))
blob = self._get_blob(self._encode_name(name))
return blob.make_public()
this is slow because it looks up blob object by name then return it so I can make it public.
what is the most efficient way of setting object ACL to be public-read before saving the object to google storage ?