Azure Blob 列表分页

2024-01-05

我的容器中有 3000 个文件。在我的 gridview 中,我显示容器 blob 列表,但 3000 太多了,对性能不利(我的想法:))。

我需要一个分页代码,例如我的网格页面大小是 50,我将在 gridview 中的第一页的容器中显示前 50 个 blob。当然,我需要在 pageindex 中更改更多代码:)

还是不影响性能?


我正在寻找 JAVA 中的分页示例,出于某种原因,谷歌将这个问题列为前 3 名。无论如何,我找到了一个解决方案,如果有人有兴趣如何使用 java 和最新的 MS azure 客户端进行分页,请点击这里。

void listAllForContainer(BlobContainerClient container) {
    String token = null;
    do {
        PagedResponse<BlobItem> pr = container
                .listBlobs(options, token, Duration.ofSeconds(60))
                .iterableByPage()
                .iterator()
                .next();

        token = pr.getContinuationToken();
        List<BlobItem> pageItems = pr.getValue();
        pageItems.forEach(i->System.out.println(i.getName()));

    } while (token != null);
}

蔚蓝神器

    <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-storage-blob</artifactId>
        <version>12.X.X</version>
    </dependency>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Azure Blob 列表分页 的相关文章

随机推荐