fileCollection.delete(file.id());
chunkCollection.delete(new Query().field("file_id").is(file.id()));
}
private GridFsFile findFile(String fileName) {
List<GridFsFile> files = fileCollection.query(new Query().field("filename").is(fileName));
if (files.isEmpty()) {
throw new NotFoundException("File not found: " + fileName);
}
return files.get(0);
}