A file name that contains a hash(#) in the name like (image#12.png) in m Blob storage. Usually, we are generating a SAS token to download the file. Regular files are downloading properly with that SAS token-based URL. But the file name which contains has not been downloaded. Below is the error I am getting in the browser.
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:ab30ae48-001e-000f-46da-8969ff000000 Time:2021-08-05T09:15:13.1495259Z</Message>
<AuthenticationErrorDetail>Signature did not match. String to sign used was r 2021-08-05T09:15:11Z 2021-08-08T03:15:11Z /blob/<blob-account-name>/container/image#14.png 2020-08-04 b </AuthenticationErrorDetail>
</Error>
Below is my Node.js code to generate the SAS-based URL.
let originalname = "image#12.png";
let FPath = "<BlobPath>";
let urlParts = url.parse(FPath);
var blobName = urlParts.path.split('/').slice(2).join('/');
blobName = decodeURIComponent(blobName);
if (urlParts.hash !== null) {
blobName += decodeURIComponent(urlParts.hash);
blobName = blobName.replace(originalname, encodeURIComponent(originalname));
}
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
let expiry = new Date();
expiry.setHours(expiry.getMinutes() + 60);
const sasToken = generateBlobSASQueryParameters(
{
containerName: containerClient._containerName,
blobName: blobName,
startsOn: new Date(),
expiresOn: expiry,
permissions: BlobSASPermissions.parse('r')
},
sharedKeyCredential
);
const sasUrl = `${decodeURIComponent(blockBlobClient.url)}?${sasToken}`;
That SasUrl
URL I am accessing through the browser.
Can anyone help me with this?