A Google App Engine microservice to support file uploads for static websites.
- The microservice uses the App Engine app's identity to create a temporary signed URL. The upload destination is validated and and normalized.
- The frontend uses the signed URL to upload the file directly to Google Cloud Storage.
- The frontend can then, separately record the uploaded destination (i.e. by submitting it through a form).
- Clone this repository.
- Use
make project=GCP_PROJECT deploy
to deploy a standalone service. - Ensure the CORS policy is updated:
make bucket=BUCKET cors
. (Updatecors-policy.json
to restrict origins.)
By default, files are uploaded to:
/{application-default bucket}/grow-ext-file-upload/{timestamp}/{file}.{ext}
The upload destination can be customized by using env variables:
GROW_FILE_UPLOAD_BUCKET
– Override the bucketGROW_FILE_UPLOAD_FOLDER
– Override the subfolder
Ensure the application-default service account has access to create files in the appropriate bucket.