如何在从节点上传到 Azure 后获取 Blob URL.js

How can I get the blob URL after a file upload to Azure from node.js

本文关键字:Azure 获取 Blob js URL 节点      更新时间:2023-09-26

我将文件上传到 Azure 中的 blob 存储,现在我想获取用于上传的 Azure 链接。我正在使用节点.js下面是我的代码:

blobService.createContainerIfNotExists('trimfaces', {
  publicAccessLevel: 'blob'
}, function(error, result, response) {
  if (!error) {
    // if result = true, container was created.
    // if result = false, container already existed.
  }
});

您可能想调用blobService.getUrl(containerName, blobName) 。API 文档位于此处:http://azure.github.io/azure-storage-node/BlobService.html#getUrl

[更新]

v10 或更高版本的版本控制文档位于:https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-storage-blob/12.0.0/classes/blockblobclient.html#url

根据文档,这是使用 node 列出 blob 的方法:

blobSvc.listBlobsSegmented('mycontainer', null, function(error, result, response){
  if(!error){
    // result.entries contains the entries
    // If not all blobs were returned, result.continuationToken has the continuation token.
  }
});

可在此处查看 Azure 存储 Blob 的完整文档:https://azure.microsoft.com/en-us/documentation/articles/storage-nodejs-how-to-use-blob-storage/