if (!databaseService.getDbList().contains(dbName)) {
throw new DatabaseException(ErrorCodes.DB_DOES_NOT_EXISTS, "DB [" + dbName + "] DOES NOT EXIST");
}
GridFS gridFS = new GridFS(mongoInstance.getDB(dbName), bucketName);
GridFSInputFile fsInputFile = gridFS.createFile(inputStream, fileData.getFileName());
fsInputFile.setContentType(formData.getMediaType().toString());
fsInputFile.save();
String objectId = JSON.serialize(fsInputFile.getId());
JSONObject obj = new JSONObject();
obj.put("name", fsInputFile.getFilename());
obj.put("size", fsInputFile.getLength());
obj.put("url", String.format("services/%s/%s/gridfs/getfile?id=%s&download=%s&connectionId=%s&ts=%s", dbName, bucketName, objectId, false, connectionId, new Date()));
obj.put("delete_url", String.format("services/%s/%s/gridfs/dropfile?id=%s&connectionId=%s&ts=%s", dbName, bucketName, objectId, connectionId, new Date().getTime()));
obj.put("delete_type", "GET");
result.put(obj);