Google cloud storage - how to limit size of user uploads?

老子叫甜甜 提交于 2019-12-22 10:53:06

问题


I'm building a service where users can upload images. I want to prevent users from uploading files bigger than 5mb.

Right now I create a 'signed url' for cloud storage user PUT and GET requests. Is there any way I can limit the size of a user upload?

I don't want users to start uploading extremely large files by mistake or with malicious intent.


回答1:


There are three ways to control access to Google Cloud Storage buckets and objects:

Access Control Lists (ACLs), which provide a way to specify read or write access for specified Google accounts and groups.

Signed URLs (Query String Authentication), which provide a way to give time-limited read or write access to anyone in possession of the URL, regardless of whether they have a Google account or not.

Signed Policy Documents, which provide a way to specify what can be uploaded to a bucket. Policy documents allow greater control over size, content type, and other upload characteristics than signed URLs, and can be used by website owners to allow visitors to upload files to Google Cloud Storage.

In this case, you'll need to use the Signed Policy Documents access control method. Take a look at this POST Object article and this case for examples.



来源:https://stackoverflow.com/questions/32395592/google-cloud-storage-how-to-limit-size-of-user-uploads

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!