| | |
| | | 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); |
| | | |
| | |
| | | int end = dataSection.indexOf("\"", start); |
| | | if (start > 11 && end > start) { |
| | | String filePath = dataSection.substring(start, end); |
| | | // 去除转义字符 |
| | | filePath = filePath.replace("\\", ""); |
| | | log.info("提取到文件路径: {}", filePath); |
| | | return filePath; |
| | | } |
| | |
| | | if (start > 16 && end > start) { |
| | | String thumbnailPath = dataSection.substring(start, end); |
| | | log.info("提取到缩略图路径: {}", thumbnailPath); |
| | | thumbnailPath = thumbnailPath.replace("\\", ""); // 去除转义字符 |
| | | return thumbnailPath; |
| | | } |
| | | } |
| | |
| | | if (start > 16 && end > start) { |
| | | String thumbnailPath = response.substring(start, end); |
| | | log.info("提取到缩略图路径(旧格式): {}", thumbnailPath); |
| | | thumbnailPath = thumbnailPath.replace("\\", ""); // 去除转义字符 |
| | | return thumbnailPath; |
| | | } |
| | | } |
| | |
| | | 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) { |