use of com.mongodb.gridfs.GridFSInputFile in project play-cookbook by spinscale.
the class GridFsHelper method storeFile.
public static void storeFile(String title, File image) throws IOException {
GridFS fs = getGridFS();
// delete the old file
fs.remove(image.getName());
GridFSInputFile gridFile = fs.createFile(image);
gridFile.save();
gridFile.setContentType("image/" + FilenameUtils.getExtension(image.getName()));
gridFile.setFilename(image.getName());
gridFile.put("title", title);
gridFile.save();
}
Aggregations