maven
2 天以前 01c28e0b62f5cea71dd9378fefa28b7177ffedba
src/main/java/com/ruoyi/other/service/impl/TempFileServiceImpl.java
@@ -6,6 +6,7 @@
import com.ruoyi.other.pojo.TempFile;
import com.ruoyi.other.service.TempFileService;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.util.URLEncoder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
@@ -38,10 +39,12 @@
        String tempId = UUID.randomUUID().toString();
        String originalFilename = file.getOriginalFilename();
        if(originalFilename == null) throw new IOException("文件名不能为空");
        String encodedFilename = java.net.URLEncoder.encode(originalFilename, StandardCharsets.UTF_8);
        Path tempFilePath = Paths.get(tempDir, tempId + "_" + encodedFilename);
//        URLEncoder urlEncoder = new URLEncoder();
//        String encodedFilename = urlEncoder.encode(originalFilename, StandardCharsets.UTF_8);
//        encodedFilename = encodedFilename.replaceAll("%2E",".");
//        Path tempFilePath = Paths.get(tempDir, tempId + "_" + encodedFilename);
//        Path tempFilePath = Paths.get(tempDir, tempId + "_" + file.getOriginalFilename());
        Path tempFilePath = Paths.get(tempDir, tempId + "_" + file.getOriginalFilename());
        // 2. 确保目录存在
        Path parentDir = tempFilePath.getParent();