|
|
@@ -3,6 +3,7 @@ package com.xjrsoft.common.utils;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.*;
|
|
|
+import java.nio.charset.Charset;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.util.List;
|
|
|
@@ -177,10 +178,11 @@ public class FileZipUtil {
|
|
|
*/
|
|
|
public static ZipFile convertToZipFile(MultipartFile multipartFile) throws IOException {
|
|
|
// 创建临时文件
|
|
|
- Path tempPath = Files.createTempFile("temp", ".zip");
|
|
|
+ String originalFilename = multipartFile.getOriginalFilename();
|
|
|
+ Path tempPath = Files.createTempFile("temp", originalFilename.substring(originalFilename.lastIndexOf('.')));
|
|
|
multipartFile.transferTo(tempPath); // 将MultipartFile内容写入临时文件
|
|
|
|
|
|
// 使用ZipFile读取临时文件
|
|
|
- return new ZipFile(tempPath.toFile());
|
|
|
+ return new ZipFile(tempPath.toFile(), Charset.forName("GBK"));
|
|
|
}
|
|
|
}
|