Thank you so much, Sam!
When you send a file chunk, do you send any additional data with it (e.g. chunk number) or does the recipient know what to expect (from the file info sent before) and the file chunk itself is enough? I'm thinking if I actually need to append any data to the file chunk (chunk number and so on) or if it should be enough to set the recipient in the correct state - wait for file info, wait for file data etc.
Thanks for the code for writing to the file system - it would take me ages to figure it out myself. I'm currently using "window.URL.createObjectURL(blob)" which is much, much shorter, but of course requires the whole file to be loaded to memory.
Couldn't sender send these 16KB chunks in blocks (e.g. 64 chunks per block) and wait for the recipient to confirm the whole block instead? Not sure how much faster that would be...