jjzjj

GridFSDBFile

全部标签

java - spring boot 2.0.1 版本中的 GridFSDBFile

我正在尝试将springboot1.5.7迁移到其最新版本realease2.0.1。在旧版本中,我使用此语法来恢复文件。GridFSDBFilegridFsdbFile=gridFsTemplate.findOne(newQuery(Criteria.where("_id").is(fileId)));你知道新版本会怎么做吗?我需要file.setInputStream(gridFsdbFile.getInputStream());太好了! 最佳答案 GridFSFilegridFsdbFile=gridFsTemplate.fi

java - 如何在 Spring Rest Call 中使用 GridFS 从 Mongodb 发送和检索图像?

我已经使用SpringData和GridFs模板从MongoDB检索了图像所以我不知道如何将检索到的输入流返回给用户。Saytheyrequestedforthehttp://host.com/appleasaspringrestcall.Nowmyapplicationprocesstherequestbyusingthenameappleitretrievestheappleimagefromamongodbdatabase.Nowwithoutsavinganywhereiwanttodisplaytheresponseasanimagetouserthatwillshowhtt

spring - GridFSDBFile 无法转换为 org.springframework.web.multipart.MultipartFile

我正在编写一个springmvcwebapp,它使用类型为MultipartFile的图像,我将其转换为byte[]然后转换为Inputstream和使用GridFsTemplate将其存储在MongoDB中。现在的问题是我想在网页中显示存储的图像,但每当我尝试这样做时,数据库都会将图像文件作为GridFSDBFiles返回,因此抛出以下异常:java.lang.ClassCastException:com.mongodb.gridfs.GridFSDBFilecannotbecasttoorg.springframework.web.multipart.MultipartFile这是