use of com.emc.object.s3.bean.S3Object in project pravega by pravega.
the class S3FileSystemImpl method listObjects.
@Override
public ListObjectsResult listObjects(String bucketName, String prefix) {
ListObjectsResult result = new ListObjectsResult();
ArrayList<S3Object> list = new ArrayList<>();
Path path = Paths.get(this.baseDir, bucketName, prefix);
try {
if (Files.exists(path)) {
if (Files.isDirectory(path)) {
Files.list(path).forEach(file -> {
addFileAsObjectToList(file, list, bucketName);
});
} else {
addFileAsObjectToList(path, list, bucketName);
}
}
} catch (IOException e) {
throw new S3Exception("NoSuchKey", HttpStatus.SC_NOT_FOUND, "NoSuchKey", "");
}
result.setObjects(list);
return result;
}
use of com.emc.object.s3.bean.S3Object in project pravega by pravega.
the class S3FileSystemImpl method addFileAsObjectToList.
// Adds a single file to the list as an object.
private void addFileAsObjectToList(Path path, ArrayList<S3Object> list, String bucketName) {
S3Object object = new S3Object();
object.setKey(path.toString().replaceFirst(Paths.get(this.baseDir, bucketName).toString(), ""));
list.add(object);
}
Aggregations