你可以在 nodejs 中使用 getBlobToStream 或 getBlobToText 来获取 blob 数据。
下面是读取 blob 所需的 function.json:
{
"bindings": [
{
"name": "Blob",
"type": "blobTrigger",
"dataType": "binary",
"direction": "in",
"path": "folderpath",
"connection": "CONN_STR"
}
]
}
与您提供的代码相关,我对其进行了一些更改,如下所示:
var blobName = 'BlobName';
blobService.getBlobToText(
containerName,
blobName,
function(err, blobContent, blob) {
if (err) {
console.error("Couldn't download blob %s", blobName);
console.error(err);
} else {
console.log("Sucessfully downloaded blob %s", blobName);
console.log(blobContent);
}
});
Converting to the stream as below:
module.exports = async function (context, myBlob) {
context.log(context.bindings.myBlob.toString());
context.log("Blob:", context.bindingData.blobTrigger, "\n Blob Size:", myBlob.length, "Bytes");
};
还可以查看SO 了解更多信息。