You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package cn.zhouyafeng.itchat4j.api;
import java.io.File;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
/**
* 辅助工具类,该类暂时未用,请忽略
*
* @author https://github.com/yaphone
* @date 创建时间2017年5月22日 下午10:34:46
* @version 1.0
*
*/
public class AssistTools {
private static OkHttpClient client = new OkHttpClient();
private static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png");
public static boolean sendQrPicToServer(String username, String password, String uploadUrl, String localPath)
throws IOException {
File file = new File(localPath);
RequestBody requestBody = new MultipartBody.Builder().addFormDataPart("username", username)
.addFormDataPart("password", password)
.addFormDataPart("file", file.getName(), RequestBody.create(MEDIA_TYPE_PNG, file)).build();
Request request = new Request.Builder().url(uploadUrl).post(requestBody).build();
Call call = client.newCall(request);
try {
Response response = call.execute();
System.out.println(response.body().string());
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
}

Powered by TurnKey Linux.