ImageNetworkTest0

This commit is contained in:
liujiahua123123 2019-09-11 20:21:02 +08:00
parent 4b4fd3b942
commit 79f7cd627a
2 changed files with 42 additions and 0 deletions

View File

@ -53,6 +53,12 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.12.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@ -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();
}
}
}