From 79f7cd627a83ed415774cda2eaaceecd6083679d Mon Sep 17 00:00:00 2001 From: liujiahua123123 Date: Wed, 11 Sep 2019 20:21:02 +0800 Subject: [PATCH] ImageNetworkTest0 --- mirai-core/pom.xml | 6 ++++ .../mamoe/mirai/utils/ImageNetworkUtils.java | 36 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 mirai-core/src/main/java/net/mamoe/mirai/utils/ImageNetworkUtils.java diff --git a/mirai-core/pom.xml b/mirai-core/pom.xml index fac520c0f..987962a9e 100644 --- a/mirai-core/pom.xml +++ b/mirai-core/pom.xml @@ -53,6 +53,12 @@ compile + + org.jsoup + jsoup + 1.12.1 + compile + diff --git a/mirai-core/src/main/java/net/mamoe/mirai/utils/ImageNetworkUtils.java b/mirai-core/src/main/java/net/mamoe/mirai/utils/ImageNetworkUtils.java new file mode 100644 index 000000000..abaf38321 --- /dev/null +++ b/mirai-core/src/main/java/net/mamoe/mirai/utils/ImageNetworkUtils.java @@ -0,0 +1,36 @@ +package net.mamoe.mirai.utils; + +import org.jsoup.Connection; +import org.jsoup.Jsoup; + +import java.io.IOException; + +public class ImageNetworkUtils { + public static void postImage(String ukey, int fileSize, String g_uin,String groupCode, String img){ + //http://htdata2.qq.com/cgi-bin/httpconn?htcmd=0x6ff0071&ver=5515&term=pc&ukey=” + 删全部空 (ukey) + “&filesize=” + 到文本 (fileSize) + “&range=0&uin=” + g_uin + “&groupcode=” + Group + StringBuilder builder = new StringBuilder("http://htdata2.qq.com/cgi-bin/httpconn?htcmd=0x6ff0071&ver=5515&term=pc"); + builder.append("&ukey=") + .append(ukey.trim()) + .append("&filezise=").append(fileSize) + .append("&range=").append("0") + .append("&uin=").append(g_uin) + .append("&groupcode=").append(groupCode); + + try { + Connection.Response response = Jsoup.connect(builder.toString()) + .ignoreContentType(true) + .requestBody(img) + .followRedirects(true) + .userAgent("QQClient") + .header("Content-Length","" + fileSize) + .execute(); + + System.out.println(response.statusCode()); + System.out.println(response.statusMessage()); + System.out.println(response.body()); + + } catch (IOException e) { + e.printStackTrace(); + } + } +}