wlzboy
3 天以前 40a8157440e3b906da8f52e07d939d78c3f4c313
ruoyi-system/src/main/java/com/ruoyi/system/file/FileUploadServiceImpl.java
@@ -85,7 +85,7 @@
            log.info("开始上传文件到PHP接口: fileName={}, targetPath={}", fileName, targetPath);
            
            // 调用PHP上传接口
            String response = HttpUtils.postFile(legacyConfig.getFileServerUrl(), params, fileName);
            String response = HttpUtils.postFile(legacyConfig.getFileUploadUrl(), params, fileName);
            
            log.info("PHP接口响应: {}", response);
            
@@ -107,7 +107,7 @@
        try {
            // 从URL下载文件
            byte[] fileBytes = downloadFromUrl(fileUrl);
            if (fileBytes == null || fileBytes.length == 0) {
            if (fileBytes.length == 0) {
                return FileUploadResponse.error("从URL下载文件失败");
            }
            
@@ -258,7 +258,7 @@
        }
        
        try {
            log.info("开始解析PHP响应: {}", response);
//            log.info("开始解析PHP响应: {}", response);
            
            // 根据PHP接口的实际返回格式进行解析
            // PHP返回格式: {"success": true, "message": "文件上传成功", "data": {...}}
@@ -267,7 +267,7 @@
                String filePath = extractFilePathFromResponse(response);
                String thumbnailPath = extractThumbnailPathFromResponse(response);
                
                log.info("解析结果 - filePath: {}, thumbnailPath: {}", filePath, thumbnailPath);
//                log.info("解析结果 - filePath: {}, thumbnailPath: {}", filePath, thumbnailPath);
                
                // 创建响应对象
                FileUploadResponse uploadResponse = FileUploadResponse.success(filePath, "上传成功");
@@ -305,6 +305,8 @@
                        int end = dataSection.indexOf("\"", start);
                        if (start > 11 && end > start) {
                            String filePath = dataSection.substring(start, end);
                            // 去除转义字符
                            filePath = filePath.replace("\\", "");
                            log.info("提取到文件路径: {}", filePath);
                            return filePath;
                        }
@@ -346,6 +348,7 @@
                        if (start > 16 && end > start) {
                            String thumbnailPath = dataSection.substring(start, end);
                            log.info("提取到缩略图路径: {}", thumbnailPath);
                            thumbnailPath = thumbnailPath.replace("\\", ""); // 去除转义字符
                            return thumbnailPath;
                        }
                    }
@@ -359,6 +362,7 @@
                if (start > 16 && end > start) {
                    String thumbnailPath = response.substring(start, end);
                    log.info("提取到缩略图路径(旧格式): {}", thumbnailPath);
                    thumbnailPath = thumbnailPath.replace("\\", ""); // 去除转义字符
                    return thumbnailPath;
                }
            }
@@ -471,20 +475,7 @@
                return uploadResponse;
            }
            
            // 如果是图片,生成缩略图
            if (isImage && uploadResponse.getFilePath() != null) {
                String originalPath = uploadResponse.getFilePath();
                String thumbnailPath = generateThumbnailPath(originalPath);
                // 生成缩略图
                if (createThumbnail(originalPath, thumbnailPath, 100, 0)) {
                    uploadResponse.setThumbnailPath(thumbnailPath);
                    log.info("缩略图生成成功:{}", thumbnailPath);
                } else {
                    log.warn("缩略图生成失败:{}", originalPath);
                }
            }
//            log.info("上传文件成功 文件:{} 缩略:{}",uploadResponse.getFilePath(),uploadResponse.getThumbnailPath());
            return uploadResponse;
            
        } catch (Exception e) {