-
+
-
-
+
{{ scope.row.dictLabel }}
{{ scope.row.dictLabel }}
-
-
+
@@ -109,27 +107,11 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/ruoyi-video/src/main/java/com/ruoyi/video/thread/detector/HttpYoloDetector.java b/ruoyi-video/src/main/java/com/ruoyi/video/thread/detector/HttpYoloDetector.java
index c3d49bf..d9a989e 100644
--- a/ruoyi-video/src/main/java/com/ruoyi/video/thread/detector/HttpYoloDetector.java
+++ b/ruoyi-video/src/main/java/com/ruoyi/video/thread/detector/HttpYoloDetector.java
@@ -71,28 +71,23 @@ public class HttpYoloDetector implements YoloDetector {
byte[] jpgBytes = new byte[(int)(buffer.capacity())];
buffer.get(jpgBytes);
buffer.deallocate();
-
// 准备HTTP请求参数
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
MultiValueMap body = new LinkedMultiValueMap<>();
- // 仅发送文件,model_name 放到查询参数
+ // 1. 添加文件参数(正确)
body.add("file", new CustomByteArrayResource(jpgBytes, "image.jpg"));
+ // 2. 添加 model_name 作为表单参数(关键修改)
+ body.add("model_name", modelName); // 直接添加到表单数据中
HttpEntity> requestEntity = new HttpEntity<>(body, headers);
- // 将 model_name 作为查询参数
- String urlWithQuery;
- try {
- String encoded = java.net.URLEncoder.encode(modelName, java.nio.charset.StandardCharsets.UTF_8.toString());
- urlWithQuery = apiUrl + (apiUrl.contains("?") ? "&" : "?") + "model_name=" + encoded;
- } catch (Exception ex) {
- urlWithQuery = apiUrl + (apiUrl.contains("?") ? "&" : "?") + "model_name=" + modelName;
- }
+ // 不需要拼接查询参数,直接使用原始API URL
+ String url = apiUrl;
- // 发送请求到Python服务
- ResponseEntity response = restTemplate.postForEntity(urlWithQuery, requestEntity, String.class);
+ // 发送请求
+ ResponseEntity response = restTemplate.postForEntity(url, requestEntity, String.class);
String responseBody = response.getBody();
if (!response.getStatusCode().is2xxSuccessful()) {
log.error("HTTP检测失败: status={}, body={}", response.getStatusCodeValue(), responseBody);