Im trying to publish upload progress for images, uploading them using okhttp as my client and mimecraft to package up the multipart file.
I have added logs to write the bytecount when data gets written to the socket (in chunks of 4kb if i can tell correctly) and then uploaded.
The problem is that, while i call flush on the outputstream every time a chunk of data is written, nothing seems to get uploaded until ~800kb has been written to the outputstream. Once it hits that point, it seems to upload ~100kb, and the app then writes another 100kb to the outputstream (like its freed up space and can write a bit more) and continues on.
The result of this is that (over a 1.2mb file) the first 800kb gets written/reported almost instantly, and then it starts uploading (tracked through charles network software) and will then start a read/write/upload of 100kb over the next few seconds, then once ive written the last bytes to the outputstream, the app reports 100% of the upload is written. This sint true though as the network client is still uploading the last 800kb that still is in the network buffer, and it sits there for another 5-10 seconds uploading that, then finishes the request.
Has anyone had this experience, or knows if this is a common problem in okhttp?
Cheers
EDIT: if i upload a file less than 800kb, ive tested some 250kb and 500kb, and they all get written 100% to the stream instantly before being uploaded, but a 3mb image will still upload 800kb, and then tick away in roughly 100kb chunks, and the writing loop sits there writing another 100kb each time some gets uploaded.