if (bucketName.equals("")) {
throw new CollectionException(ErrorCodes.COLLECTION_NAME_EMPTY, "Bucket Name Empty");
}
JSONArray result = new JSONArray();
FormDataContentDisposition fileData = formData.getFormDataContentDisposition();
try {
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());