android - okhttp3 - how to control network usage (upload throttling) -
i trying upload image using okhttp3 library.
what happens that, when upload starts, okhttp takes available bandwidth making impossible make other connection app or other app.
my code is:
progressrequestbody filebody = new progressrequestbody( requestbody.create(mediatype.parse(getmimetype(sourcefile)), sourcefile), new progressrequestbody.listener() { @override public void onprogress(int progress) { //update progress } }); requestbody requestbody = new multipartbody.builder() .settype(multipartbody.form) .addformdatapart("key", key) .addformdatapart("file", sourcefile.getname(), filebody) .build(); request request = new request.builder() .url(global.server_url + "upload") .addheader("authorization", global.g_userinfo.getsessionid()) .post(requestbody) .build(); response response = okhttpclient.newcall(request).execute(); responsestring = response.body().string(); statuscode = response.code();
Comments
Post a Comment