From 7df667ff109e5cdccb61305140f81d60856f4ff4 Mon Sep 17 00:00:00 2001
From: yaozc2021 <yaozc@yhzhg.cn>
Date: Wed, 25 Dec 2024 07:38:29 +0000
Subject: [PATCH] Merge branch 'wcd-2411-update' of http://192.168.1.110:5678/r/pms-upgrade into wcd
---
eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java b/eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
index 74402d6..a650f69 100644
--- a/eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
+++ b/eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
@@ -351,6 +351,24 @@
}
}
+ /**
+ * 下载ZIP
+ */
+ public static void downloadZip(ByteArrayOutputStream byteArrayOutputStream, HttpServletResponse response) throws IOException {
+ // response为HttpServletResponse对象
+ response.setContentType("application/zip");
+ // test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
+ response.setHeader("Content-Disposition", "attachment;filename=file.zip");
+ // ServletOutputStream
+ ServletOutputStream out = response.getOutputStream();
+ // 写入
+ out.write(byteArrayOutputStream.toByteArray());
+ // flush
+ out.flush();
+ //此处记得关闭输出Servlet流
+ IoUtil.close(out);
+ }
+
public static String getMd5(File file) {
return getMd5(getByte(file));
}
--
Gitblit v1.9.3