Hi there,
I have a system which uploads to a server file by file and displays a progress bar on file upload progress, then underneath a second progress bar which I want to indicate percentage of batch complete across all files queued to upload.
Information and algorithms I can work out are:
Bytes Sent / Total Bytes To Send = First progress bar (eg. 512KB of 1024KB (50%))
That works fine. However supposing I have two other files left to upload, but both file sizes are unknown (as this is only known once the file is about to commence upload, at which point it is compressed and file size is determined) how would I go about making my third progress bar?
I didn't think this would be possible as I would need "Total Bytes Sent" / "Total Bytes To Send", to replicate the logic of my first progress bar on a larger scale, however I did get a version working: "Current file number we are on" / "total number of files to send" returning the percentage through the batch, however obviously will not incrementally update and it's pretty crude.
So on further thinking I thought if I could incorporate the current file % with this algorithm I could perhaps get the correct progress percentage of my batch's current point.
I tried this algorithm, but alas to no such avail (sorry to any math heads, it's probably quite apparent why it won't work)
("Current file number we are on" / "total number of files to send") * ("Bytes Sent" / "Total Bytes To Send")
For example I thought I was on the right track when testing with this example: 2/3 (2nd of 3rd file) = 66% (this is right so far) but then when I added * 0.20 (for indicating only 20% of 2nd file has uploaded) we went back to 13%. What I need is only a little over 33%! I did try the inverse at 0.80 and a (2/3 * (2/3 * 0.2))
Can this be done without knowing entire bytes in batch to upload?
Please help! Thank you!