MongoDB
 sql >> Base de Dados >  >> NoSQL >> MongoDB

GridFSDBFile na versão Spring Boot 2.0.1

GridFSFile gridFsdbFile = gridFsTemplate.findOne(new Query(Criteria.where("_id").is(id)));

GridFSDownloadStream gridFSDownloadStream = gridFSBucket.openDownloadStream(gridFsdbFile.getObjectId());
GridFsResource gridFsResource = new GridFsResource(gridFsdbFile,gridFSDownloadStream );

então
file.setInputStream(gridFsResource.getInputStream());

Você pode definir gridFSBucket no MongoConfiguration assim
@Bean public GridFSBucket getGridFSBuckets() {
MongoDatabase db = mongoDbFactory().getDb();
return GridFSBuckets.create(db);
}