- The client asks the backend to upload a file.
- The backend returns a session URI to the client (Resumable Uploads with the XML API).
- With this session URI the client has permission to upload a file to Google Cloud Storage.
¿How to configure the session URI to allow only a maximum file size?
Unfortunately, starting a resumable upload and passing a session URI to a client does not provide a way to limit file size.
There is, however, a way to do this. Instead of using a resumable PUT upload initiated by the server, have the client initiate its own POST upload using a signed policy document. Policy documents allow the server to provide a list of requirements that an upload must fulfill, one of which is an acceptable range of file sizes. Specifically, you'll need to include this section:
You can read about policy documents and how to craft them here: https://cloud.google.com/storage/docs/xml-api/post-object#policydocument