Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createFileListIterator的limit参数大于0小于1000未生效 #564

Open
GabbyMrH opened this issue Oct 24, 2022 · 1 comment
Open

createFileListIterator的limit参数大于0小于1000未生效 #564

GabbyMrH opened this issue Oct 24, 2022 · 1 comment

Comments

@GabbyMrH
Copy link

代码如下

OssFileEntity为业务所需封装的数据实体,可忽略

        // 构造一个带指定 Region 对象的配置类
        Configuration configuration = new Configuration(Region.region0());
        Auth auth = Auth.create(qiniuOssProperty.getAccessKey(), qiniuOssProperty.getSecretKey());
        BucketManager bucketManager = new BucketManager(auth, configuration);
        try {
            // 文件名前缀
            String prefix = "";
            // 指定目录分隔符,列出所有公共前缀(模拟列出目录效果)。缺省值为空字符串
            String delimiter = "";

            // 列举空间文件列表(以100做示例)
            BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(qiniuOssProperty.getBucket(), prefix, 100, delimiter);
            List<OssFileEntity> ossFileEntityList = new ArrayList<>();
            while (fileListIterator.hasNext()) {
                // 处理获取的file list结果
                FileInfo[] items = fileListIterator.next();
                for (FileInfo item : items) {
                    ossFileEntityList.add(OssFileEntity.builder()
                            .domain(qiniuOssProperty.getDomain())
                            .url(qiniuOssProperty.getDomain() + "/" + item.key)
                            .suffix(FilenameUtils.getExtension(item.key))
                            .build());
                }
            }
            return ossFileEntityList;
        } catch (Exception e) {
            throw new BaseException(e.getMessage());
        }

返回结果

无论传测试limit为100还是50都是返回超过预期设置的limit

image

@YangSen-qn
Copy link
Contributor

@ GabbyMrH

Limit 限制的是单次请求返回的数量,也即下面代码中 items 数组的长度:

FileInfo[] items = fileListIterator.next();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants