app.js 760 B

12345678910111213141516171819202122232425
  1. import { Uppy } from '@uppy/core'
  2. import Dashboard from '@uppy/dashboard'
  3. import Tus from '@uppy/tus'
  4. import Unsplash from '@uppy/unsplash'
  5. import Url from '@uppy/url'
  6. import '@uppy/core/dist/style.css'
  7. import '@uppy/dashboard/dist/style.css'
  8. function onShouldRetry (err, retryAttempt, options, next) {
  9. if (err?.originalResponse?.getStatus() === 418) {
  10. return true
  11. }
  12. return next(err)
  13. }
  14. const companionUrl = 'http://localhost:3020'
  15. const uppy = new Uppy()
  16. .use(Dashboard, { target: '#app', inline: true })
  17. .use(Tus, { endpoint: 'https://tusd.tusdemo.net/files', onShouldRetry })
  18. .use(Url, { target: Dashboard, companionUrl })
  19. .use(Unsplash, { target: Dashboard, companionUrl })
  20. // Keep this here to access uppy in tests
  21. window.uppy = uppy