i am using NSURLConnection and it's delegates to upload file to the server. I am using below method to get how much data gas been send till now.
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten
totalBytesWritten:(NSInteger)totalBytesWritten
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
I am getting output as below:
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 32768
bytesWritten : 2408
bytesWritten : 3828
bytesWritten : 3828
bytesWritten : 2840
bytesWritten : 4260
bytesWritten : 5680
bytesWritten : 2840
bytesWritten : 7100
My question is: Why am I getting inconsistent data? For first few records, I am getting maximum byteWritten value and for the next it's very moderate.
Can anyone help to understand this inconsistency?
I came to the conclusion that connection starts sending maximum bytes through the network. As and when server starts responding to the incoming data this byte size gets finalise according to network strength.
Thank you.