如何通过node.js中的@azure/storage-blob获取BLOB存储中文件的安全url? [英] How to get secure url of File in blob storage via @azure/storage-blob in node.js?

查看:38
本文介绍了如何通过node.js中的@azure/storage-blob获取BLOB存储中文件的安全url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用@azure/storage-blob,我可以上传文件,但如何检索它?您知道如何获取存储的SAS URL吗?

我需要生成几分钟后过期的url,并且url是基于令牌的,因为容器不是用于公共访问的。请帮助node.js或指导我一些插件,帮助获取/生成BLOB存储中该文件的SAS url。提前感谢您!

推荐答案

要在Blob上生成共享访问签名(SASURL),可以使用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();

这篇关于如何通过node.js中的@azure/storage-blob获取BLOB存储中文件的安全url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆