Home > OS >  Is there Azure SAS storage restrictions by content type and size?
Is there Azure SAS storage restrictions by content type and size?

Time:10-01

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.

Is there such an ability?

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

CodePudding user response:

No. The restrictions available for SAS are permissions, start/end dates and IP address.

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. 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. 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.

  • Related