feat: 在线编辑文件加载方式改为URI

This commit is contained in:
2024-10-09 15:53:04 +08:00
parent 947b075ae0
commit 9ebe71d162
@@ -22,6 +22,8 @@ import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
@@ -54,6 +56,12 @@ public class ProcessFileServiceImpl implements IProcessFileService {
OSSFile ossFile = new OSSFile();
try {
URL fileUrl = getClass().getClassLoader().getResource("wordTemplate/DOCX.docx");
if (fileUrl != null) {
Path filePath = Paths.get(fileUrl.toURI());
log.info("File path: " + filePath);
} else {
log.info("File not found!");
}
File file = new File(fileUrl.getFile());
FileInputStream fileInputStream = new FileInputStream(file);
MultipartFile multipartFile = new MockMultipartFile("file", model + ".docx", "application/octet-stream", fileInputStream);