|
@@ -20,7 +20,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+import java.io.BufferedInputStream;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
+import java.net.URI;
|
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
@@ -94,11 +96,8 @@ public class CommonController {
|
|
|
public void download(@RequestParam String filepath, HttpServletResponse response) {
|
|
public void download(@RequestParam String filepath, HttpServletResponse response) {
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
// 文件名称转换,用户列表_uuid.xlsx -> 用户列表_1637469159968.xlsx
|
|
// 文件名称转换,用户列表_uuid.xlsx -> 用户列表_1637469159968.xlsx
|
|
|
- String filepathConvert = StrUtil.subBefore(filepath, "_", true)
|
|
|
|
|
- + "_" + System.currentTimeMillis() + "."
|
|
|
|
|
- + StrUtil.subAfter(filepath, ".", true);
|
|
|
|
|
- setAttachmentResponseHeader(response, FileUtil.getName(filepathConvert));
|
|
|
|
|
- FileUtil.writeToStream(AppConfig.getUploadDir() + filepath, response.getOutputStream());
|
|
|
|
|
|
|
+ setAttachmentResponseHeader(response, FileUtil.getName(filepath));
|
|
|
|
|
+ FileUtil.writeToStream(FileUtil.file(URI.create(filepath)),response.getOutputStream());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|