简体   繁体   English

Azure SAS 是否有内容类型和大小的存储限制?

[英]Is there Azure SAS storage restrictions by content type and size?

When creating a pre-signed url (SAS token) for a blob storage object with read/write access, I'd like to limit the content type and size of the item being uploaded by someone.在为具有读/写访问权限的 blob 存储 object 创建预签名 url(SAS 令牌)时,我想限制某人上传的项目的内容类型和大小。

Is there such an ability?有这种能力吗?

https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview

No. The restrictions available for SAS are permissions, start/end dates and IP address.否。SAS 的可用限制是权限、开始/结束日期和 IP 地址。

If you want to limit the content type and size, you would have to handle it on your own.如果要限制内容类型和大小,则必须自己处理。

One possible way would be to get the SAS token on demand for the file user is trying to upload.一种可能的方法是为用户尝试上传的文件按需获取 SAS 令牌。 When a user tries to upload a file, first thing you would do is take the file metadata (size, content type) and hit an API endpoint.当用户尝试上传文件时,您要做的第一件事就是获取文件元数据(大小、内容类型)并点击 API 端点。 This API endpoint will validate the metadata and if everything is correct it will return the SAS URL for that file otherwise return an error.这个 API 端点将验证元数据,如果一切正确,它将返回该文件的 SAS URL 否则返回错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM