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. const companionUrl = 'http://localhost:3020'
  9. const uppy = new Uppy()
  10. .use(Dashboard, { target: '#app', inline: true })
  11. .use(Tus, { endpoint: 'https://tusd.tusdemo.net/files', onShouldRetry })
  12. .use(Url, { target: Dashboard, companionUrl })
  13. .use(Unsplash, { target: Dashboard, companionUrl })
  14. function onShouldRetry (err, retryAttempt, options, next) {
  15. if (err?.originalResponse?.getStatus() === 418) {
  16. return true
  17. }
  18. return next(err)
  19. }
  20. // Keep this here to access uppy in tests
  21. window.uppy = uppy