From badc83cad7a47ec00af8a45a3d1ecddb696bb17b Mon Sep 17 00:00:00 2001
From: qirong <2032486488@qq.com>
Date: 星期三, 06 十二月 2023 15:12:26 +0800
Subject: [PATCH] 修改

---
 ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/uitil/HttpUtils.java |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 1 deletions(-)

diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/uitil/HttpUtils.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/uitil/HttpUtils.java
index 937a7e2..5d1b2ea 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/uitil/HttpUtils.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/uitil/HttpUtils.java
@@ -14,6 +14,7 @@
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.dromara.common.oss.entity.SynchronousRequest;
+import org.dromara.common.oss.entity.VideoRequest;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.*;
@@ -117,7 +118,7 @@
     }
 
     /**
-     * 涓婁紶鍚屾
+     * 涓婁紶鍚屾 瑙嗛涓撶綉
      * @param url
      * @param entity
      * @return
@@ -152,6 +153,63 @@
     }
 
     /**
+     * 涓婁紶鍚屾 瑙嗛涓撶綉
+     * @param url
+     * @param entity
+     * @return
+     * @throws IOException
+     */
+    public static String sendPostRequest2(String url, VideoRequest entity) throws IOException {
+        org.apache.http.client.HttpClient httpClient = HttpClientBuilder.create().build();
+        HttpPost httpPost = new HttpPost(url);
+
+        ContentType contentType = ContentType.create("multipart/form-data", StandardCharsets.UTF_8);
+        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+        builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
+
+        // 娣诲姞MultipartFile鍙傛暟
+        builder.addBinaryBody("file", entity.getFile().getBytes(), ContentType.MULTIPART_FORM_DATA, entity.getFile().getOriginalFilename());
+
+        // 娣诲姞String鍙傛暟
+        builder.addTextBody("fileName", entity.getFileName(), contentType);
+
+        HttpEntity multipart = builder.build();
+        httpPost.setEntity(multipart);
+
+        HttpResponse response = httpClient.execute(httpPost);
+        String responseBody = EntityUtils.toString(response.getEntity());
+        System.out.println("Response: " + responseBody);
+        return responseBody;
+    }
+
+    /**
+     * 涓婁紶鍚屾2
+     * @param url
+     * @param entity
+     * @return
+     * @throws IOException
+     */
+    public static String sendPostRequestTwo(String url, SynchronousRequest entity) throws IOException {
+        org.apache.http.client.HttpClient httpClient = HttpClientBuilder.create().build();
+        HttpPost httpPost = new HttpPost(url);
+
+        ContentType contentType = ContentType.create("multipart/form-data", StandardCharsets.UTF_8);
+        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+        builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
+
+        // 娣诲姞MultipartFile鍙傛暟
+        builder.addBinaryBody("file", entity.getFile().getBytes(), ContentType.MULTIPART_FORM_DATA, entity.getFile().getOriginalFilename());
+
+        HttpEntity multipart = builder.build();
+        httpPost.setEntity(multipart);
+
+        HttpResponse response = httpClient.execute(httpPost);
+        String responseBody = EntityUtils.toString(response.getEntity());
+        System.out.println("Response: " + responseBody);
+        return responseBody;
+    }
+
+    /**
      * 鍒犻櫎鍚屾
      * @param url
 //     * @param parameter

--
Gitblit v1.8.0