Proposal
Add more cloud backends to the existing MediaStorage system, starting with Google Cloud
Storage. MediaStorage already ships Local and S3 backends; this adds GCSMediaStorage
as the next one — and I'm happy to follow with others (e.g. Azure Blob) after.
from piccolo_api.media.gcs import GCSMediaStorage
storage = GCSMediaStorage(
column=Movie.poster,
bucket_name="my-bucket",
folder_name="movie_posters",
)
Design
Mirrors S3MediaStorage method-for-method (async + _sync worker via ThreadPoolExecutor,
reusing the base's generate_file_key), using google-cloud-storage. Optional dependency as
a gcs extra (pip install 'piccolo_api[gcs]'), like s3.
No new framework — MediaStorage's six abstract methods are already the provider interface,
so each new backend is just one module + extra + docs.
One GCS doc note: v4 signing needs a private key. Locally that's a service-account JSON;
on GCP compute (Cloud Run) the ADC has no private key, so signing goes through the IAM
signBlob API (grant the runtime SA roles/iam.serviceAccountTokenCreator).
Questions before I PR
- Happy for GCS to live in
piccolo_api, extending the existing backends?
google-cloud-storage + a gcs extra — agreeable?
- Interested in further providers after GCS? If so, I could factor a small shared
CloudMediaStorage mixin once there's a second one to share it with.
The GCS backend is implemented and tested (faked storage.Client, no live GCS) — happy to
open the PR once you confirm the direction. Thanks!
Proposal
Add more cloud backends to the existing
MediaStoragesystem, starting with Google CloudStorage.
MediaStoragealready shipsLocalandS3backends; this addsGCSMediaStorageas the next one — and I'm happy to follow with others (e.g. Azure Blob) after.
Design
Mirrors
S3MediaStoragemethod-for-method (async +_syncworker viaThreadPoolExecutor,reusing the base's
generate_file_key), usinggoogle-cloud-storage. Optional dependency asa
gcsextra (pip install 'piccolo_api[gcs]'), likes3.No new framework —
MediaStorage's six abstract methods are already the provider interface,so each new backend is just one module + extra + docs.
One GCS doc note: v4 signing needs a private key. Locally that's a service-account JSON;
on GCP compute (Cloud Run) the ADC has no private key, so signing goes through the IAM
signBlobAPI (grant the runtime SAroles/iam.serviceAccountTokenCreator).Questions before I PR
piccolo_api, extending the existing backends?google-cloud-storage+ agcsextra — agreeable?CloudMediaStoragemixin once there's a second one to share it with.The GCS backend is implemented and tested (faked
storage.Client, no live GCS) — happy toopen the PR once you confirm the direction. Thanks!