public String execute() throws Exception {
return saveBlob();
}
private String saveBlob() throws IOException {
GridFS gridFS = mongoConnection.getGridFS();
BufferedInputStream bis = new BufferedInputStream(is);
String md5 = calculateMd5(bis);
GridFSDBFile gridFile = gridFS.findOne(new BasicDBObject("md5", md5));
if (gridFile != null) {
is.close();
return md5;
}
GridFSInputFile gridFSInputFile = gridFS.createFile(bis, true);
gridFSInputFile.save();
return gridFSInputFile.getMD5();
}