【问题标题】:How can I get the blob URL after a file upload to Azure from node.js从 node.js 将文件上传到 Azure 后如何获取 blob URL
【发布时间】:2020-07-29 13:22:56
【问题描述】:

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

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

【问题讨论】:

  • 链接是这样的http://<storage-account-name>.blob.core.windows.net/<container-name>/<blob-name>
  • 您的代码未显示您上传 Blob 的方式。您是否为此编写了代码,或者您是在谈论手动上传 Blob,然后以编程方式查找它们?

标签: javascript node.js azure azure-blob-storage


【解决方案1】:

您可能想致电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

【讨论】:

    【解决方案2】:

    根据文档,这是使用节点列出 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/

    【讨论】:

      猜你喜欢
      • 2013-06-02
      • 2019-12-22
      • 2021-12-30
      • 2020-04-12
      • 2020-06-12
      • 2019-04-10
      • 2016-02-13
      • 2021-01-01
      • 2020-04-12
      相关资源
      最近更新 更多