Golden Retriever

Golden Retriever plugin saves selected files in your browser cache (Local Storage for metadata, then Service Worker for all blobs + IndexedDB for small blobs), so that if the browser crashes, Uppy can restore everything and continue uploading like nothing happened. Read more about it on the blog.

1. Bundle your own service worker sw.js file with Uppy Golden Retriever’s service worker. If you’re using Browserify, just bundle it separately, for Webpack there is a plugin serviceworker-webpack-plugin.

// sw.js
require('uppy/lib/GoldenRetriever/ServiceWorker.js')

2. Register it in your app entry point:

// you app.js entry point
uppy.use(RestoreFiles, {serviceWorker: true})
uppy.run()
const isServiceWorkerControllerReady = new Promise(resolve => {
if (navigator.serviceWorker.controller) return resolve()
navigator.serviceWorker.addEventListener('controllerchange', e => resolve())
})
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/sw.js') // path to your bundled service worker with Golden Retriever service worker
.then((registration) => {
console.log('ServiceWorker registration successful with scope: ', registration.scope)
return isServiceWorkerControllerReady
})
.then(() => {
uppy.emit('core:file-sw-ready')
})
.catch((error) => {
console.log('Registration failed with ' + error)
})
}