HarmonyOS 鸿蒙HTTP post请求,怎么实现 OutputStream 上传方式
HarmonyOS 鸿蒙HTTP post请求,怎么实现 OutputStream 上传方式
URL url = new URL(uploadUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setRequestMethod(“POST”);
con.addRequestProperty(“Content-Type”, “multipart/form-data; boundary=” + boundary);
FileInputStream fs = new FileInputStream(file);
OutputStream output = con.getOutputStream();
output.write(textbody);
output.write(binarybody);
byte[] buff = new byte[1024];
int r;
while ((r = fs.read(buff, 0, buff.length)) >= 0) {
output.write(buff, 0, r);
}
output.write(terminate);
output.close();
fs.close();
这段代码怎么转成ArkTs
关于HarmonyOS 鸿蒙HTTP post请求,怎么实现 OutputStream 上传方式的问题,您也可以访问:https://www.itying.com/category-93-b0.html 联系官网客服。
2 回复
找HarmonyOS工作还需要会Flutter的哦,有需要Flutter教程的可以学学大地老师的教程,很不错,B站免费学的哦:https://www.bilibili.com/video/BV1S4411E7LY/?p=17
试一下用三方库ohos/axios