如何从Azure容器获取文件夹列表?
我想要在nodejs中的所有文件夹和文件在一个azure色的容器中
我正在使用azure存储库获取blob,但无法find任何示例来列出容器下的所有文件夹。 我在auzure中倾销(出口)我的anaylitics数据到存储容器。 现在我试图阅读这些文件
我的存储结构像
ios-analytics-full/ios_06cd82e4db0845b9bef73c5b22bea2fa/Event/2016-09-29/18/270b58c-04d7-4e5d-a503-cdce24a3940c_20160929_184723.blob
我想读取为每一天创build的所有文件夹和这些文件夹下的文件
var containerName = "assist-ios-analytics-full"; blobService.listBlobsSegmented(containerName, null, {maxResults : 10}, function(err, result) { if (err) { console.log("Couldn't list blobs for container %s", containerName); console.error(err); } else { console.log('Successfully listed blobs for container %s', containerName); console.log(result.entries); console.log(result.continuationToken); res.json(result); } });
最新的文件夹将是今天的date
ios-analytics-full/ios_06cd82e4db0845b9bef73c5b22bea2fa/Event/2017-05-31/18/270b58c-04d7-4e5d-a503-cdce24a3940c_20160929_184723.blob
你想要使用的函数是listBlobsSegmentedWithPrefix
。
你将要做的是将prefix
指定为ios_06cd82e4db0845b9bef73c5b22bea2fa/Event/{date eg 2017-05-31}
和options.delimiter
as ""
,这将确保所有的斑点返回,其中名称以上面的前缀开头。
所以你的代码将是:
blobService.listBlobsSegmentedWithPrefix(containerName, 'ios_06cd82e4db0845b9bef73c5b22bea2fa/Event/2017-05-31', null, {delimiter: "", maxResults : 10}, function(err, result) { if (err) { console.log("Couldn't list blobs for container %s", containerName); console.error(err); } else { console.log('Successfully listed blobs for container %s', containerName); console.log(result.entries); console.log(result.continuationToken); res.json(result); } });