Reputation: 534
¿How to configure the session URI to allow only a maximum file size?
Upvotes: 4
Views: 4601
Reputation: 38369
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:
["content-length-range", <min_range>, <max_range>]
You can read about policy documents and how to craft them here: https://cloud.google.com/storage/docs/xml-api/post-object#policydocument
Upvotes: 4