Search in sources :

Example 1 with FileListing

use of com.qiniu.storage.model.FileListing in project oss-spring-boot-starter by ArtIsLong.

the class QiNiuOssClient method getInfo.

@SneakyThrows
@Override
public OssInfo getInfo(String targetName, Boolean isRecursion) {
    String key = getKey(targetName, false);
    OssInfo ossInfo = getBaseInfo(targetName);
    if (isRecursion && isDirectory(key)) {
        FileListing listFiles = bucketManager.listFiles(getBucket(), key, "", 1000, "/");
        System.out.println(listFiles);
        List<OssInfo> fileOssInfos = new ArrayList<>();
        List<OssInfo> directoryInfos = new ArrayList<>();
        if (ObjectUtil.isNotEmpty(listFiles.items)) {
            for (FileInfo fileInfo : listFiles.items) {
                fileOssInfos.add(getInfo(OssPathUtil.replaceKey(fileInfo.key, getBasePath(), false), false));
            }
        }
        if (ObjectUtil.isNotEmpty(listFiles.commonPrefixes)) {
            for (String commonPrefix : listFiles.commonPrefixes) {
                String target = OssPathUtil.replaceKey(commonPrefix, getBasePath(), true);
                directoryInfos.add(getInfo(target, true));
            }
        }
        if (ObjectUtil.isNotEmpty(fileOssInfos) && fileOssInfos.get(0) instanceof FileOssInfo) {
            ReflectUtil.setFieldValue(ossInfo, "fileInfos", fileOssInfos);
        }
        if (ObjectUtil.isNotEmpty(directoryInfos) && directoryInfos.get(0) instanceof DirectoryOssInfo) {
            ReflectUtil.setFieldValue(ossInfo, "directoryInfos", directoryInfos);
        }
    }
    return ossInfo;
}
Also used : FileInfo(com.qiniu.storage.model.FileInfo) FileListing(com.qiniu.storage.model.FileListing) DirectoryOssInfo(io.github.artislong.model.DirectoryOssInfo) ArrayList(java.util.ArrayList) FileOssInfo(io.github.artislong.model.FileOssInfo) OssInfo(io.github.artislong.model.OssInfo) DirectoryOssInfo(io.github.artislong.model.DirectoryOssInfo) FileOssInfo(io.github.artislong.model.FileOssInfo) SneakyThrows(lombok.SneakyThrows)

Example 2 with FileListing

use of com.qiniu.storage.model.FileListing in project alluxio by Alluxio.

the class KodoUnderFileSystem method getObjectListingChunk.

@Nullable
@Override
protected ObjectListingChunk getObjectListingChunk(String key, boolean recursive) throws IOException {
    String delimiter = recursive ? "" : PATH_SEPARATOR;
    key = PathUtils.normalizePath(key, PATH_SEPARATOR);
    key = key.equals(PATH_SEPARATOR) ? "" : key;
    FileListing result = getObjectListingChunk(key, getListingChunkLength(mUfsConf), delimiter);
    if (result != null) {
        return new KodoObjectListingChunk(result, getListingChunkLength(mUfsConf), delimiter, key);
    }
    return null;
}
Also used : FileListing(com.qiniu.storage.model.FileListing) Nullable(javax.annotation.Nullable)

Aggregations

FileListing (com.qiniu.storage.model.FileListing)2 FileInfo (com.qiniu.storage.model.FileInfo)1 DirectoryOssInfo (io.github.artislong.model.DirectoryOssInfo)1 FileOssInfo (io.github.artislong.model.FileOssInfo)1 OssInfo (io.github.artislong.model.OssInfo)1 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 SneakyThrows (lombok.SneakyThrows)1