Skip to content

Commit

Permalink
fix: 修复打包部署后,下载用户导入模板异常问题
Browse files Browse the repository at this point in the history
  • Loading branch information
KAI authored and Charles7c committed Aug 7, 2024
1 parent 359d902 commit c7ffc67
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.io.file.FileNameUtil;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.*;
Expand Down Expand Up @@ -78,7 +78,6 @@
import top.continew.starter.extension.crud.service.CommonUserService;
import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.time.Duration;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -130,8 +129,7 @@ public Long add(UserDO user) {
@Override
public void downloadImportUserTemplate(HttpServletResponse response) throws IOException {
try {
BufferedInputStream inputStream = FileUtil.getInputStream("templates/import/userImportTemplate.xlsx");
byte[] bytes = IoUtil.readBytes(inputStream);
byte[] bytes = ResourceUtil.readBytes("templates/import/userImportTemplate.xlsx");
response.setHeader("Content-Disposition", "attachment;filename=" + URLUtil.encode("用户导入模板.xlsx"));
response.addHeader("Content-Length", String.valueOf(bytes.length));
response.setHeader("Access-Control-Allow-Origin", "*");
Expand Down

0 comments on commit c7ffc67

Please sign in to comment.