MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

GridFSDBFile nella versione 2.0.1 dell'avvio primaverile

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

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

poi

file.setInputStream(gridFsResource.getInputStream());

Puoi definire gridFSBucket in MongoConfiguration in questo modo

@Bean public GridFSBucket getGridFSBuckets() {
MongoDatabase db = mongoDbFactory().getDb();
return GridFSBuckets.create(db);
}