James Gilchrist
James Gilchrist

Reputation: 2312

How can I list blobs in Azure's blob storage w/o recursively fetching all blobs

For Reference Here's Some Applicable Code:

const service = storage.createBlobService(connectionString);
service.listBlobsSegemented(containerName, null, (err, data) => {
  if (err) {
    throw new Error();
  }
  data.entries.forEach(blob => {
    console.log('blob', blob)
  })
})

The problem is that data.entries includes EVERY SINGLE blob in the container. My container's structure looks something like this:

I can easily only fetch things within /archive with listBlobsSegmentedWithPrefix such as:

service.listBlobsSegmentedWithPrefix(containerName, 'archive', null, 
  (err, data) => {
    ...
  }
)

However, I don't see a way to ONLY get the blobs at the root level.

Upvotes: 0

Views: 1228

Answers (1)

James Gilchrist
James Gilchrist

Reputation: 2312

Well, I was at a loss so I just randomly tried setting the delimiter to '/' and it worked. Too bad the documentation doesn't quite describe it's use as such...

Solution:

service.listBlobsSegmented(containerName, null, {delmiter: '/'}, (e, d) => {
  ....
})

Upvotes: 1

Related Questions