简体   繁体   English

如何通过 node.js 中的@azure/storage-blob 在 blob 存储中获取文件的安全 url?

[英]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.

相关问题 使用 node.js '@azure/storage-blob' 包从 Azure-Storage 流式传输视频 - Stream a video from Azure-Storage by using node.js '@azure/storage-blob' package @azure/storage-blob 如何从 Azuree 获取 uploadStream 图像 url 的结果 - @azure/storage-blob how to get result of uploadStream image url from Azuree 如何通过 Node.js 在 Azure Blob 存储上上传 PDF 文件? - How to Upload PDF File on Azure Blob Storage via Node.js? Azure Blob存储Node.js后端 - azure blob storage node.js backend NodeJS '@azure/storage-blob':上传文件时如何设置 Blob 服务属性 - NodeJS '@azure/storage-blob': How do set Blob Service Properties when uploading a file 如何使用@azure/storage-blob sdk append 一个 blob 文件? (NodeJS) - How do I append a blob file using @azure/storage-blob sdk ? (NodeJS) Azure Blob 存储和 Node.js - Azure blob storage and Node.js 如何通过Azure网站上的Node.js应用程序将大文件的上传流通过管道传输到Azure Blob存储? - How to pipe upload stream of large files to Azure Blob storage via Node.js app on Azure Websites? 列出 Azure 中的 Blob 存储和读取流 Node.js - List blob from Azure Blob Storage and Readstream in Node.js 如何通过 Azure blob 存储在 node.js 中提供 CDN 图像 URL? - How to serve CDN image urls in node.js via Azure blob storage?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM