onCompleted is not called
See original GitHub issue- Android Upload Service version (e.g. 3.0.3):
- Android version and API version (e.g. 6.0.1 API 23):
I expect the onCompleted callback to be called when the upload is finished But it’s not called
This is my request code:
final String uploadId =
new net.gotev.uploadservice.MultipartUploadRequest(getApplicationContext(), "https://www.motolife.bg/post_avatar.php")
.addFileToUpload(filename, "photo")
.addParameter("parameter","value")
.setDelegate(new net.gotev.uploadservice.UploadStatusDelegate() {
@Override
public void onProgress(net.gotev.uploadservice.UploadInfo uploadInfo) {
Log.e("gotev","onProgress eltstr="+uploadInfo.getElapsedTimeString()+" elt="+uploadInfo.getElapsedTime()+" ratestr="+
uploadInfo.getUploadRateString()+" prc="+uploadInfo.getProgressPercent()+" tb="+uploadInfo.getTotalBytes()+" ub="+uploadInfo.getUploadedBytes());
}
@Override
public void onError(net.gotev.uploadservice.UploadInfo uploadInfo, Exception e) {
Log.e("gotev","onError "+e.getMessage() + e.getStackTrace());
}
@Override
public void onCompleted(net.gotev.uploadservice.UploadInfo uploadInfo, net.gotev.uploadservice.ServerResponse serverResponse) {
Log.e("gotev","onCompleted "+serverResponse.getHttpCode()+" "+serverResponse.getBodyAsString());
}
@Override
public void onCancelled(net.gotev.uploadservice.UploadInfo uploadInfo) {
Log.e("gotev","onCancelled "+uploadInfo);
}
}).startUpload();
This is my library initialization code
net.gotev.uploadservice.UploadService.NAMESPACE = bg.motolife.app.BuildConfig.APPLICATION_ID;
And this is my logcat output
08-19 19:31:21.649 1706-1706/bg.motolife.app E/gotev: uploadId=7e9235a9-de5a-4ead-8e2f-93ca25f30b20
08-19 19:31:21.938 1706-1706/bg.motolife.app E/gotev: onProgress eltstr=0s elt=248 ratestr=0 bit/s prc=0 tb=174870 ub=103
{"st":0}
The request is successfully received by the server. But there is now output from the onCompleted callback
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
onCompleted not called when useQuery refetch finished #3709
Im using Apollo 3.0.1 on a React Native project and I'm facing the same issues, useLazyQuery does not run onCompleted after I call...
Read more >onCompleted callback is not calling for 2nd ... - Stack Overflow
It seems to be a known issue that Apollo's onCompleted option works differently between queries fulfilled over the network and by the cache....
Read more >onCompleted option not available for refetchQueries - Help
I wanna execute a query on completion of a mutation [every time an action occurs/mutation is called]. now apollo provides an option to...
Read more >Component.onCompleted doesn't seem to be called
onCompleted : console.log("This will not be printed") } ... plugin first and only then attaches the slots that handle the call to console.log....
Read more >Solution: onCompleted - Thinkster.io
Solution: onCompleted ... Join our newsletter! Get exclusive content, resources, and more! Subscribe. 1-2 emails per week, no ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Updated the Monitoring upload status wiki page:
Please make use of markdown syntax to improve readability the next time, as I’ve noted in the asking for help wiki page. I’ve done that for you this time in your posts.
Made some tests using the node.js demo server and the demo app provided in the examples, and this is what I get in the LogCat:
So those CR and LF characters are added by your PHP server-side script in the response. Here you can see the code which is being executed in the
onCompleted
method. If you dump network traffic I’m pretty sure you will see CR and LF at the beginning of the response body coming from your server.To ensure the server response encoding I’ve modified the PHP script the following way: header(‘Content-Type: application/json; charset=utf-8’); echo utf8_encode(json_encode(array(“st”=>0)));
On the client side in the onCompleted method I inserted the following code int code = serverResponse.getHttpCode(); Log.e(“gotev”, “onCompleted3 " + code); byte[] ba = serverResponse.getBody(); for (int j=0; j<ba.length; j++) { Log.e(“byte”,String.format(”%02X ", ba[j])); } String str2 = new String(ba, Charset.forName(“UTF8”)); Log.e(“gotev”, "strs equ= " + resps.equals(str2)); JSONObject jo = new JSONObject(resps); int st = jo.getInt(“st”); Log.e(“gotev”, “onCompleted5 st=” + st);
And I’ve got the following in the Logcat in my Android Studio 08-20 12:13:50.999 20111-20111/bg.motolife.app E/gotev: onCompleted3 200 {“st”:0} 08-20 12:13:51.000 20111-20111/bg.motolife.app E/byte: 0D 08-20 12:13:51.000 20111-20111/bg.motolife.app E/byte: 0A 08-20 12:13:51.000 20111-20111/bg.motolife.app E/byte: 7B 08-20 12:13:51.000 20111-20111/bg.motolife.app E/byte: 22 08-20 12:13:51.000 20111-20111/bg.motolife.app E/byte: 73 08-20 12:13:51.000 20111-20111/bg.motolife.app E/byte: 74 08-20 12:13:51.000 20111-20111/bg.motolife.app E/byte: 22 08-20 12:13:51.000 20111-20111/bg.motolife.app E/byte: 3A 08-20 12:13:51.000 20111-20111/bg.motolife.app E/byte: 30 08-20 12:13:51.000 20111-20111/bg.motolife.app E/byte: 7D 08-20 12:13:51.000 20111-20111/bg.motolife.app E/gotev: strs equ= true 08-20 12:13:51.001 20111-20111/bg.motolife.app E/gotev: onCompleted5 st=0
See, in the second string i don’t see any string header because of new line and carriage return characters in the string And then In the byte loop we see first 2 bytes are exactly line_feed and carriage_return
From where are these two bytes in the beginning of the serverResponse?