如何从 Azure 容器中获取文件夹列表?
How to get folder list from azure container?
我想在 nodejs 中获取 azure 容器中的所有文件夹和文件
我正在使用 azure-storage 库来获取 blob,但找不到任何示例来列出容器下的所有文件夹。我正在将分析数据转储(导出)到 auzure 中的存储容器中。现在我试着阅读这些文件
我的存储结构像
ios-analytics-full/ios_06cd82e4db0845b9bef73c5b22bea2fa/Event/2016-09-29/18/270b58c-04d7-4e5d-a503-cdce24a3940c_20160929_184723.blob
我想读取每天创建的所有文件夹和这些文件夹下的文件
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);
}
});
最新的文件夹是今天
ios-analytics-full/ios_06cd82e4db0845b9bef73c5b22bea2fa/Event/2017-05-31/18/270b58c-04d7-4e5d-a503-cdce24a3940c_20160929_184723.blob
您要使用的函数是listBlobsSegmentedWithPrefix
。
你要做的是将 prefix
指定为 ios_06cd82e4db0845b9bef73c5b22bea2fa/Event/{date e.g. 2017-05-31}
并将 options.delimiter
指定为 ""
这将确保返回名称以前缀开头的所有 blob以上。
因此您的代码将是:
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);
}
});
我想在 nodejs 中获取 azure 容器中的所有文件夹和文件
我正在使用 azure-storage 库来获取 blob,但找不到任何示例来列出容器下的所有文件夹。我正在将分析数据转储(导出)到 auzure 中的存储容器中。现在我试着阅读这些文件
我的存储结构像
ios-analytics-full/ios_06cd82e4db0845b9bef73c5b22bea2fa/Event/2016-09-29/18/270b58c-04d7-4e5d-a503-cdce24a3940c_20160929_184723.blob
我想读取每天创建的所有文件夹和这些文件夹下的文件
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);
}
});
最新的文件夹是今天
ios-analytics-full/ios_06cd82e4db0845b9bef73c5b22bea2fa/Event/2017-05-31/18/270b58c-04d7-4e5d-a503-cdce24a3940c_20160929_184723.blob
您要使用的函数是listBlobsSegmentedWithPrefix
。
你要做的是将 prefix
指定为 ios_06cd82e4db0845b9bef73c5b22bea2fa/Event/{date e.g. 2017-05-31}
并将 options.delimiter
指定为 ""
这将确保返回名称以前缀开头的所有 blob以上。
因此您的代码将是:
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);
}
});