QuestionImageService.java 文件源码

java
阅读 138 收藏 0 点赞 0 评论 0

项目:metadatamanagement 作者:
/**
 * 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();      
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号