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;
}
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;
}
Aggregations