读取 xlsx 文件和 json 文件 url 使用 nodejs 在 azure blob 存储上签名

Read xlsx file and json file with url signed on azure blob storage using nodejs

我打算读取 azure blob 存储上的 xslx 和 json 文件的内容,这些文件的 urls 是用有限的生命周期签名的。

我是这样做的:

        const file = readFileSync(urlSignedBlobStorageForJSON);
        console.log(file);
        //console.log(JSON.parse(file.toString()));

我认为无需通过 azure blob 存储凭证即可访问该文件,因为 :

blobClient.createBlockBlobFromStream(containerName,filename,streamifier.createReadStream(new Buffer(filedata)), filedata.length,options,(err,result)....

我在使用 readFileSync(urlSignedBlobStorageForJSON).

时遇到错误(错误:ENOENT:没有这样的文件或目录)

如何读取此 json 文件的内容?

• 感谢 @Motra 提出有关从 blob 存储中读取 ‘.xlsx’‘.json’ 文件的问题,这些文件的 url 使用有限的 life-to-live 签名。它肯定会成为 SO 社区的宝贵补充。出于与所述相同的目的,将您的评论作为答案发布,因为其他有相同问题的人更容易找到它。

与其使用 'readFileSync(urlSignedBlobStorageForJSON)' 作为指示要从 blob 存储中读取的文件的变量,不如使用 'axios.get(urlBlobStorageData)).data' 从 blob 存储帐户中读取内容。

这将帮助您阅读“.xlsx”和“.json”文件中的内容,这些文件的 URL 已为有限 life-to-live.

签名

• 另外,请参阅下面的 SO 社区线程,了解有关在 nodejs 中正确使用上述 cmdlet 的更多详细信息:-