[英]How to get secure url of File in blob storage via @azure/storage-blob in node.js?
I am using @azure/storage-blob, i am able to upload file, but how do i retrieve it?我正在使用@azure/storage-blob,我可以上传文件,但如何检索它? any ideas how to get SAS url of storage?任何想法如何获取存储的 SAS url?
i need to generate url which expires in few minutes, and url is token based, because container is not for public access.我需要生成几分钟后过期的 url,并且 url 是基于令牌的,因为容器不用于公共访问。 kindly help in node.js or guide me with some plugin which helps to get/generate sas url for that file in blob storage.请在 node.js 中提供帮助或指导我使用一些插件来帮助获取/生成 blob 存储中该文件的 sas url。 Thank you in advance!先感谢您!
To generate a Shared Access Signature (SAS URL) on a blob, you can use generateBlobSASQueryParameters
function available in the SDK.要在 blob 上生成共享访问签名 (SAS URL),您可以使用 SDK 中提供的generateBlobSASQueryParameters
函数。
const blobSAS = generateBlobSASQueryParameters({
containerName, // Required
blobName, // Required
permissions: BlobSASPermissions.parse("r"), // Required
startsOn: new Date(), // Required
expiresOn: new Date(new Date().valueOf() + 86400) // Optional. Date type
},
sharedKeyCredential // StorageSharedKeyCredential - `new StorageSharedKeyCredential(account, accountKey)`
).toString();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.