I'm using this function call to visually display progress of file uploads to the server via a POST method.
If this method gets used how you intend it to be used, then that would mean that this method would get called multiple times during the upload process. Is this the case? Or is this method only called once?
That's a good question, because up until you just posed the question here, I assume that it got called repeatedly throughout the upload process. If it's called only once, I would expect that the progress indicator would jump to one percentage and just sit there, yet it is in fact moving as if there is progress happening. I've also added some NSLog statements along the way to check my calculations, and they do get incremented multiple times during the upload. So I think the next question is, why would it be called prematurely to a 100% completion, and then hang out until the file is really finished uploading? Is it possibly because the file is part of my form post as an attachment, and it's maybe being sent a second time?
I would bet that's exactly the case, based on what the method is called (didSendBodyData). I assume that your encoding is multipart/form? That might also mean multiple requests get sent? I'm not all too familiar with the nitty-gritty of how POSTs work via client/server.
My advice would be to check out RestKit on GH (https://github.com/RestKit/RestKit) or perhaps pose a question to their Google Group about which method should be used to get the progress of an upload. Since their request/response methods are baked in, I'm sure they have some support for this it just might be through a different avenue.
This looks like the answer to your question: http://groups.google.com/group/restkit/browse_thread/thread/9f14deae99535928?pli=1
Actually sorry, that one had to do with download progress. On further investigation, it looks like that method is the one that you should be implementing to get progress. The reason it would flip to 1 might be because of integer math? You could simplify the entire expression to:
_progressView.progress = (totalBytesWritten / totalBytesExpectedToWrite) * 100.0;
The problem might be this part that you currently have:
_progressView.progress = floor(percentComplete);
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In Apply for Membership