gpt4 book ai didi

node.js - Azure CDN 签名 url

转载 作者:行者123 更新时间:2023-12-03 06:52:23 29 4
gpt4 key购买 nike

嘿伙计们,我已经创建了一个函数来生成签名网址。但是有些签名不起作用

AZURE_CDN 与原始路径保持一致,因此它将 url/{container} 屏蔽为单个 url,因此 http://{CDN}/file.png ==> 我已经使用 get url 进行了测试,并且工作正常

我已经从控制台手动生成了一个签名的 URL,并使用 put 方法并将 URL 更改为 CDN,该 URL 工作正常(使用 postman )..

问题出在我从 Nodejs 生成的 CDN 中的 put 方法 -->

const credentials = new storage.StorageSharedKeyCredential(AZURE_STORAGE_ACCOUNT, AZURE_ACCOUNT_KEY);
const blobServiceClient = new storage.BlobServiceClient(AZURE_CDN+"/"+fileName, credentials);
const permissions = new storage.BlobSASPermissions();
permissions.write = true;

const currentDateTime = new Date();
const expiryDateTime = new Date(currentDateTime.setMinutes(currentDateTime.getMinutes()+5));//Expire the SAS token in 5 minutes.

const blobSAS = storage.generateBlobSASQueryParameters({
startsOn: new Date(),
expiresOn: expiryDateTime,
permissions: permissions,
protocol: storage.SASProtocol.Https

},
credentials
).toString();;
return blobServiceClient.url+ "?" + blobSAS;
};

我能够执行 http 选项方法但 put 方法抛出错误(使用 postman )

Signature did not match. String to sign used was w

我在这里缺少什么?

它创建的 urlurl = CDN url,直接进入容器

https://{url}/logos/09b1f812-e46e-4b88-9153-0496c130ccf8.png?sv=2021-08-06&spr=https&st=2022-08-24T10%3A23%3A10Z&se=2022-08-24T10%3A28%3A10Z&sr=b&sp=w&sig=GBqVpKLE8lw0FhB2Fa%2FqfEKMpw50A3VNgbp3bUPtY%3D

最佳答案

Signature did not match. String to sign used was w

我在我的环境中尝试过,但遇到了类似的错误。

enter image description here

  • 检查文件名、容器名等是否有错误。
  • 还要确保您提供了正确的 CDN https://< CDNname >.azureedge.net
  • header 中的格式应为 x-ms-blob-type value Blockblob

当我尝试使用正确的凭据和 SAS token 时,我成功处理并反射(reflect)在门户中。

enter image description here

Azure 门户。 enter image description here

引用: Create an account SAS - Azure Storage | Microsoft Docs

关于node.js - Azure CDN 签名 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73471202/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com