Reputation: 51
I am using XMLHttpRequest to POST 400-500k files to relatively slow ESP32-based server. The upload takes several minutes. The xhr.onreadystatechange event with readyState 4 fires at the end as expected. However xhr.upload.onprogress event that updates progress bar fires almost immediately with 100% complete.
I suspect some buffer in the many layers between the browser and the application's HTTP handler absorbs entire file, making it look like it has been transmitted already.
Question 1: Is there anything I can do on a browser side to get real time progress of data being saved in the ESP FATFS?
Question 2: I probably can use SSE from different XMLHttpRequest that would receive number of bytes already written and update progress bar. This requires additional HTTP handler and asynchronous worker thread on a server. Is there something simpler I can do?
The code here is very close to what I am doing and apparently it works for the author. Could be because the files are much bigger and server faster.
Upvotes: 0
Views: 33
Reputation: 1
i dont have much expirience with the actual code but I do know how it works. basically a post request will send back a data complete as soon as its done. what you could do is send a request for progress percentage very few seconds and wait for a response back. when you get that response update it in the HTML. I'm new to this website so sorry if I'm not much of a help. if its a buffer that absorbs the file. you could also send it byte by byte and have a system autorun on the server to compile it all together in the end and make it one file. otherwise I don't know how to help. like I said I'm new so sorry if I'm no help. i just want to try if I can :(
Upvotes: 0