备忘!!
来源:互联网 发布:好运来返奖统计软件 编辑:程序博客网 时间:2024/06/12 01:03
获取文件源Thread.currentThread().getContextClassLoader() .getResource("").getFile();
- mongodb的删除GridFS文件
if(isUseGridFS){ GridFS gridFiles = new GridFS(mongoTemplate.getDb()); gridFiles.remove(new Query().addCriteria(where("filename").regex("^"+fileInfo.getFileId())).getQueryObject());}else{ mongoTemplate.remove(new Query().addCriteria(where("id").is(fileInfo.getFileId())), FileExt.class);}
- 保存GridFS
GridFS gfs = new GridFS(mongoTemplate.getDb()); GridFSInputFile gfsFile = gfs.createFile(inputStream); gfsFile.setFilename(fileInfo.getFileId() + fileInfo.getExtension()); gfsFile.setMetaData(new BasicDBObject("aliases", fileInfo.getFileName() + fileInfo.getExtension())); gfsFile.save();
- 查找文件
InputStream inputStream = null; if(fileInfo.getUseGridFS()){ GridFS gfsPhoto = new GridFS(mongoTemplate.getDb()); GridFSDBFile gridFSDBFile = gfsPhoto.findOne(fileInfo.getFileId() + fileInfo.getExtension()); if(gridFSDBFile != null){ inputStream = gridFSDBFile.getInputStream(); } else { log.warn("文件不存在 "); response.sendError(HttpServletResponse.SC_NOT_FOUND, "文件不存在"); return false; } }
0 0
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 备忘
- 安卓开发接入微信支付功能的详细步骤(手把手教你一步一步接入,适合小白)
- 当压测遇见奥运 ——游戏服务器如何在上线时面对用户的洪荒之力
- selenium 2.0 'NoneType' object has no attribute 'send_keys'
- AndroidStudio在gradle文件中修改debug签名为正式签名
- IT-linux-top系列--top静态使用
- 备忘!!
- poj 2676 Sudoku
- 虚拟机NAT模式下ping外网
- objective-c ——代码块
- Java重难点面试(二)
- 加速WordPress网站的12个方法
- shell sort
- webstorm 使用命令行
- 今日头条的首页