main.mjs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import Uppy from '@uppy/core'
  2. import Dashboard from '@uppy/dashboard'
  3. import GoogleDrive from '@uppy/google-drive'
  4. import Instagram from '@uppy/instagram'
  5. import Dropbox from '@uppy/dropbox'
  6. import Box from '@uppy/box'
  7. import Tus from '@uppy/tus'
  8. const companionUrl = 'http://localhost:3020'
  9. window.uppy = new Uppy({
  10. id: 'uppyProvider',
  11. debug: true,
  12. autoProceed: true,
  13. })
  14. .use(Dashboard, {
  15. target: '#uppyDashboard',
  16. inline: true,
  17. })
  18. .use(GoogleDrive, { target: Dashboard, companionUrl })
  19. .use(Instagram, { target: Dashboard, companionUrl })
  20. .use(Dropbox, { target: Dashboard, companionUrl })
  21. .use(Box, { target: Dashboard, companionUrl })
  22. .use(Tus, { endpoint: 'https://tusd.tusdemo.net/files/' })
  23. if (window.location.search === '?socketerr=true') {
  24. const emitError = (file, data) => {
  25. // trigger fake socket error
  26. data.uploader.uploaderSockets[file.id].emit(
  27. 'error', { error: { message: 'nobody likes me, thats ok' } },
  28. )
  29. window.uppy.off('upload-progress', emitError)
  30. }
  31. window.uppy.on('upload-progress', emitError)
  32. }