I have a folder in blob container which have 112 blobs. I defined to get 10 blobs per page, but I am getting all 112 blobs in one page response. Please find below sample code to reproduce this issue.
PagedIterable<BlobItem> pagedIterable = getBlobContainerClient().listBlobsByHierarchy("batch/");
Iterable<PagedResponse<BlobItem>> iterableByPage = pagedIterable.iterableByPage(10);
for (PagedResponse<BlobItem> pagedResponse : iterableByPage) {
Iterator<BlobItem> iterableStream = pagedResponse.getElements().iterator();
int counter = 1;
System.err.println("counter - " + counter);
while (iterableStream.hasNext()) {
BlobItem blobItem = iterableStream.next();
LOGGER.info(counter++ +" ** listBlob name -'{}' properties-'{}', tags -'{}', version -'{}', snapshot -'{}' ***",
blobItem.getName(), blobItem.getProperties(), blobItem.getTags(), blobItem.getVersionId(),
blobItem.getSnapshot());
}
}
ScreenShot
To Reproduce
Expected behavior
Only 10 blobs should be available in one page response.
Setup (please complete the following information if applicable):
OS: window
IDE : eclipse
Version of the Library used:azure-storage-blob-12.10.0
Hi @abhikt48
Thank you for posting this issue. We will take a look at what is going wrong here.
This looks to be a duplicate of #12496 As Gauri mentioned, I'll look into reproducing this either today or Monday
@rickle-msft Just FYI, I did same testing with another approach and it is working fine. I provided custom ListBlobsOptions
and setted setMaxResultsPerPage
. But I didn't find any affect of pagedIterable.iterableByPage(10)
, looks like this is redundant. Could you please check and confirm ?
ListBlobsOptions listBlobsOptions = new ListBlobsOptions();
listBlobsOptions.setPrefix(directoryName);
listBlobsOptions.setMaxResultsPerPage(10);
PagedIterable<BlobItem> pagedIterable = getBlobContainerClient().listBlobsByHierarchy(null, listBlobsOptions , null);
Iterable<PagedResponse<BlobItem>> iterableByPage = pagedIterable.iterableByPage(10);
Could you please help me with below queries related with listBlobsByHierarchy(null, listBlobsOptions , null)
operation -
listBlobsOptions.setPrefix(directoryName + "prefix");
- I didn't find any option to set directory specifically in ListBlobsOptions
or BlobContainerClient.listBlobsByHierarchy(null, listBlobsOptions , null)
. Can I assume that - directoryName can be provide via listBlobsOptions.setPrefix()
only ? Please confirm.listBlobsByHierarchy
opertaion. Could you please check and confirm if we have any option to check size of listOld SDK - Length of list
ResultSegment<ListBlobItem> listBlobResult = provider.getBlobListInDirectory(containerName, directoryName,
blobPrefix, index, continuationToken);
totalItems = listBlobResult.getLength();
Please suggest your opinion on above queries, so i can proceed futher.
Regards,
Abhishek Kumar