Skip to content

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

@GabbyMrH

Description

@GabbyMrH

代码如下

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions