【问题标题】:With Nodejs, why can I read from one Azure blob container but not from another?使用 Nodejs,为什么我可以从一个 Azure blob 容器中读取,而不能从另一个容器中读取?
【发布时间】:2015-03-27 23:43:15
【问题描述】:

我有一个 nodejs 应用程序作为 Azure 云服务中的工作角色运行,我有两个 blob 存储容器,应用程序在响应某些用户请求时将从这些容器中读取。

这是我的设置:
使用 azure-storage 包与我的 blob 存储接口。
两个容器,每个容器都保存用户在某个时候可能会要求的不同类型的文件。

我使用以下代码将文件流式传输到 HTTP 响应:

exports.getBlobToStream = function(containerName, fileName, res) {
    var blobService = azure.createBlobService();

    blobService.getBlobProperties(containerName, fileName, function(error, properties, status){
        if(error || !status.isSuccessful)
        {
            res.header('Content-Type', "text/plain");
            res.status(404).send("File " + fileName + " not found");
        }
        else
        {
            res.header('Content-Type', properties.contentType);
            res.header('Content-Disposition', 'attachment; filename=' + fileName);
            blobService.createReadStream(containerName, fileName).pipe(res);
        }
    });
};

一个重要的

在过去,我从任一容器读取都没有问题。在我对这个问题的研究中,我在https://github.com/Azure/azure-sdk-for-node/issues/434 的包罗万象的 azure-sdk-for-node 上发现了一个相同(但已过时)的问题。解决该问题的解决方案也解决了我的问题,但我不明白为什么。特别是当我可以从同一个应用程序中的另一个容器中读取并使用相同的代码而没有任何问题时。

我可以接受解决方案,但想了解发生了什么。有什么想法或建议吗?

【问题讨论】:

    标签: node.js azure azure-storage


    【解决方案1】:

    @winsome,感谢您向我们提出这个问题。如果设置了 EMULATED,则意味着代码将调用本地存储模拟器而不是真实存储帐户,并且预计会失败。关于在 EMULATED 下工作的一个容器,猜测是您的本地存储模拟器也具有相同的容器。请检查。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-29
      • 2020-06-21
      • 1970-01-01
      • 2020-03-29
      • 2011-12-27
      • 1970-01-01
      • 2020-01-27
      相关资源
      最近更新 更多