简体   繁体   中英

Node.js reading a blob with azure and creating a SAS token

So I am currently writing some code that gets a container and then selects a blob and makes a SAS token. which all currently work but I get a error when I try to open the link.

The error being given is this.

AuthenticationFailed Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:somethingsomething The specified signed resource is not allowed for the this resource level

 const test = () => { const keyCredit = new StorageSharedKeyCredential('storageaccount', 'key') const sasOptions = { containerName: 'compliance', blobName: 'swo_compliance.csv', }; sasOptions.expiresOn = new Date(new Date().valueOf() + 3600 * 1000); sasOptions.permissions = BlobSASPermissions.parse("r"); const sasToken = generateBlobSASQueryParameters(sasOptions, keyCredit).toString(); console.log(`SAS token for blob container is: url/?${sasToken}`); return `url/?${sasToken}`; }

I tried to reproduce the scenario in my system able to download the blob using the sas token

While you returning the return url/?${sasToken}; in your code remove the “/” just give the the return url?${sasToken};

Example URL: https://StorageName.blob.core.windows.net/test/test.txt?SASToken

I tried in my system able to download blob

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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