BAOLH
2026-11-10 4d730af0447c686133130d0116a0fa3dd82c2dca
eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
@@ -22,6 +22,7 @@
import me.zhengjie.exception.BadRequestException;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
@@ -350,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));
    }