main.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const Uppy = require('../../../src/core')
  2. const DragDrop = require('../../../src/plugins/DragDrop')
  3. const Dashboard = require('../../../src/plugins/Dashboard')
  4. const Tus = require('../../../src/plugins/Tus')
  5. const XHRUpload = require('../../../src/plugins/XHRUpload')
  6. const ProgressBar = require('../../../src/plugins/ProgressBar')
  7. // Initialise Uppy with Drag & Drop
  8. const uppyDragDrop = Uppy({
  9. id: 'uppyDragDrop',
  10. debug: true
  11. })
  12. .use(DragDrop, {
  13. target: '#uppyDragDrop'
  14. })
  15. .use(ProgressBar, { target: '#uppyDragDrop-progress' })
  16. .use(Tus, { endpoint: 'https://master.tus.io/files/' })
  17. const uppyi18n = Uppy({
  18. id: 'uppyi18n',
  19. debug: true
  20. })
  21. .use(DragDrop, {
  22. target: '#uppyi18n',
  23. locale: {
  24. strings: {
  25. dropHereOr: 'Перенесите файлы сюда или %{browse}',
  26. browse: 'выберите'
  27. }
  28. }
  29. })
  30. .use(ProgressBar, { target: '#uppyi18n-progress' })
  31. .use(XHRUpload, { endpoint: 'https://api2.transloadit.com' })
  32. const uppyDashboard = Uppy({
  33. id: 'uppyDashboard',
  34. debug: true
  35. })
  36. .use(Dashboard, {
  37. target: '#uppyDashboard',
  38. inline: true
  39. })
  40. .use(Tus, { endpoint: 'https://master.tus.io/files/' })
  41. function startXHRLimitTest (endpoint) {
  42. const uppy = Uppy({
  43. id: 'uppyXhrLimit',
  44. debug: true,
  45. autoProceed: false
  46. })
  47. .use(DragDrop, { target: '#uppyXhrLimit' })
  48. .use(XHRUpload, { endpoint, limit: 2 })
  49. uppy.uploadsStarted = 0
  50. uppy.uploadsComplete = 0
  51. uppy.on('upload-started', () => {
  52. uppy.uploadsStarted++
  53. })
  54. uppy.on('upload-success', () => {
  55. uppy.uploadsComplete++
  56. })
  57. }
  58. window.startXHRLimitTest = startXHRLimitTest
  59. console.log(uppyDragDrop, uppyi18n, uppyDashboard)