Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Background uploading #237
On a project I'm working on there's a requirement for uploading to continue even if the user refreshes the page or navigates away from it to another section of the website (another react app for example). Investigated a lot of different solutions and almost all of them don't work due to browser security, but I managed to get a proof of concept working using service workers.
It essentially uses a service worker to store a file list, then when a page loads it asks the service worker for that file list and pipes it into uppy. Uppy then detects which files are uploaded, partially uploaded etc and carries on as before. I did have a go at moving uppy into the service worker but I hit loads of problems with the tus client as it requires window.btoa etc which aren't available within a service worker.
You'll also need to have uppyServiceWorker.js on the page and you'd probably want to modify the endpoints within uppyService.js
As I said it's a complete proof of concept so nothing is configurable etc, and there's no way to destroy the worker (probably on upload completion). Would probably also only want to create the service worker when files start to get uploaded.
Either way, it's here if anyone wants it. If anyone improves it etc please share - this might be good as an Uppy plugin.
Any questions let me know!