Node.js 如何在Azure';s blob存储,不递归获取所有blob
以下是一些适用的代码供参考:Node.js 如何在Azure';s blob存储,不递归获取所有blob,node.js,azure,azure-storage,Node.js,Azure,Azure Storage,以下是一些适用的代码供参考: const service = storage.createBlobService(connectionString); service.listBlobsSegemented(containerName, null, (err, data) => { if (err) { throw new Error(); } data.entries.forEach(blob => { console.log('blob', blob)
const service = storage.createBlobService(connectionString);
service.listBlobsSegemented(containerName, null, (err, data) => {
if (err) {
throw new Error();
}
data.entries.forEach(blob => {
console.log('blob', blob)
})
})
问题在于data.entries
包含容器中的每个blob。我的容器的结构如下所示:
- 文件-1.csv
- 文件-2.csv
- 归档文件/file-1-12341234123423412.csv
- 归档文件/file-2-12341234123423412.csv
listBlobsSegmentedWithPrefix
在/archive中轻松获取内容,例如:
service.listBlobsSegmentedWithPrefix(containerName, 'archive', null,
(err, data) => {
...
}
)
但是,我看不到只在根级别获取blob的方法 嗯,我不知所措,所以我只是随机尝试将分隔符设置为“/”,结果成功了。太糟糕了,文档没有完全描述它的用途 解决方案:
service.listBlobsSegmented(containerName, null, {delmiter: '/'}, (e, d) => {
....
})