热门

最新

红包

立Flag

投票

同城

我的

发布
docuvix
道可维斯
4 年前
truedocuvix

【BeyoudSky 研发日记】 2022-05-24 今日完成了档案修改——档案追加功能,以及部分定时任务功能。明日测试定时任务加锁后多并发调用情况。

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
图片下载public String fileDownload(MultipartFile file,Long attachmentId,HttpServletResponse response) throws Exception { //需求,通过id找到文件,读取下载到桌面 //1.通过id找到图片文件 FndAppAttachment date = fndAppAttachmentMapper.getByIdAtmAttachment(attachmentId); //2.读取图片 InputStream is = new ByteArrayInputStream(date.getContent()); response.setContentType("image/**"); try { //通过文件流将图片传给前端 ServletOutputStream out = response.getOutputStream(); int len = 0; byte[] buf = new byte[1024]; //使用一个输入流从buffer里吧数据读出来 while ((len=is.read(buf,0,1024))!=1) { //用输出流往buffer里写数据,中间参数代表从哪个位置读,len代表读取的长度 out.write(buf,0,len); } out.flush(); out.close(); return "下载成功"; }catch(IOException e) { e.getMessage(); } return "下载失败";
立即登录