Progress block reaches 100 % too early while uploading a file to Parse Cloud

362 views Asked by At

I am uplading a a file to Parse as the documentation suggests.

[imageFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

} progressBlock:^(int percentDone) {
// Update your progress spinner here. percentDone will be between 0 and 100.
HUD.progress = (float)percentDone/100;
}]

The progressblock is called like 100 times where i update the HUd which seems to be ok.The problem is that the completion block is called like 10 seconds later when the progress block is called for the last time with the value 100.

As a result the hud remains on the screen with 100 % and removed 10 seconds later when the completion block is called.

I doubt that the progress block is called independent of the upload process by estimation.

P.S The file i am uploading is like 2.35 MB.

2

There are 2 answers

1
Verdant On

Try HUD.progress = (float)percentDone/100.0;

2
JoGoFo On

There is possibly a delay between the client app completing the upload and the Parse server completing processing of the upload and sending a response confirming successful save. I do not believe there is a way to determine the progress of this processing, however you could try decreasing the progress shown to allow this. For example:

HUD.progress = (float)percentDone*0.9/100;

This way it will increment to 90% and display that until the Parse server returns. Or you could check for percentDone == 100 and display some other message like "Processing...".