/**
* This method save an image into GridFS/MongoDB based on a byteArrayOutputStream.
* Existing image should be deleted before saving/updating an image
* @param questionId The id of the question to be saved
* @return return the name of the saved image in the GridFS / MongoDB.
* @throws IOException Thrown when the input stream cannot be closed
*/
public String saveQuestionImage(MultipartFile multipartFile,
String questionId) throws IOException {
try (InputStream in = multipartFile.getInputStream()) {
String contentType = mimeTypeDetector.detect(multipartFile);
GridFSFile gridFsFile = this.operations.store(in,
"/questions/" + questionId, contentType);
gridFsFile.validate();
return gridFsFile.getFilename();
}
}
QuestionImageService.java 文件源码
java
阅读 138
收藏 0
点赞 0
评论 0
项目:metadatamanagement
作者:
评论列表
文章目录