跳到主要内容

Http相关


http

post/put上传bytes流文件

提示
  • 只支持安卓9+
参数名必选类型说明
urlstring网址
localPathstring本地文件路径
headerobject协议头
methodstring请求方法,支持post/put,默认put
//坚果云上传文件
let baseUrl = "http://dav.jianguoyun.com/dav/"
let remoteFile = "dav/2.png" //远程文件
let username = "1920712147@qq.com"//坚果云账号
let davpass = "adnu5efmtb9rf2jc"//获取方式https://writer.drakeet.com/backups
let Authorization = base64(username + ":" + davpass)
let ret = ll.http.postBytes(baseUrl + remoteFile, "/sdcard/1.png", {
"Authorization": "Basic " + Authorization,
})
if (ret) {
logd("上传成功");
}

function base64(str) {
return java.lang.String(android.util.Base64.encode(java.lang.String(str).getBytes(), 2));
}
返回值类型说明
truebool是否成功