如何限制Google Cloud Storage存储桶的文件类型?
问题描述:
如何限制Google Cloud Storage存储桶的文件类型?
How can I restrict the file types of my Google Cloud Storage bucket ?
例如,我如何选择一个存储桶并精确确定其只能包含jpeg,jpg或png,并且应该拒绝任何其他类型的文件?
For example, how do I select a bucket and precise it can only contain jpeg, jpg or png and should refuse any other kind of file ?
答
请参见政策文件条件.但是,这对其他上传机制没有帮助,因此您必须采用其他方式(也许是 Cloud Function ,它会在上传时检查内容类型并删除违规者.
See policy document conditions for form POSTs. This won't help with other upload mechanisms, however, so you'll have to do that some other way (maybe a Cloud Function that does a content type check on upload and deletes violators).