}
if (_id == null) {
throw new DocumentException(ErrorCodes.DOCUMENT_EMPTY, "File is empty");
}
GridFS gridFS = new GridFS(mongoInstance.getDB(dbName), bucketName);
Object docId = JSON.parse(_id);
BasicDBObject objectId = new BasicDBObject("_id", docId);
gridFSDBFile = gridFS.findOne(objectId);
if (gridFSDBFile == null) {
throw new DocumentException(ErrorCodes.DOCUMENT_DOES_NOT_EXIST, "Document does not exist !");
}
gridFS.remove(objectId);
} catch (MongoException e) {
throw new DocumentException(ErrorCodes.DOCUMENT_DELETION_EXCEPTION, e.getMessage());
}
result = "File [" + gridFSDBFile.getFilename() + "] has been deleted.";