main.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. const Uppy = require('../../src/core/Core.js')
  2. const Dashboard = require('../../src/plugins/Dashboard')
  3. const GoogleDrive = require('../../src/plugins/GoogleDrive')
  4. const Dropbox = require('../../src/plugins/Dropbox')
  5. const Instagram = require('../../src/plugins/Instagram')
  6. const Webcam = require('../../src/plugins/Webcam')
  7. const Tus10 = require('../../src/plugins/Tus10')
  8. // const Multipart = require('../../src/plugins/Multipart')
  9. // const DragDrop = require('../../src/plugins/FileInput')
  10. const FileInput = require('../../src/plugins/FileInput')
  11. const MetaData = require('../../src/plugins/MetaData')
  12. // const Informer = require('../../src/plugins/Informer')
  13. // const StatusBar = require('../../src/plugins/StatusBar')
  14. // const DragDrop = require('../../src/plugins/DragDrop')
  15. const PROTOCOL = location.protocol === 'https:' ? 'https' : 'http'
  16. const TUS_ENDPOINT = PROTOCOL + '://master.tus.io/files/'
  17. // import ru_RU from '../../src/locales/ru_RU.js'
  18. // import MagicLog from '../../src/plugins/MagicLog'
  19. // import PersistentState from '../../src/plugins/PersistentState'
  20. const uppy = Uppy({
  21. debug: true,
  22. autoProceed: true,
  23. meta: {
  24. username: 'John'
  25. }
  26. })
  27. .use(Dashboard, {
  28. trigger: '#uppyModalOpener',
  29. // maxWidth: 350,
  30. // maxHeight: 400,
  31. inline: false,
  32. // disableStatusBar: true,
  33. // disableInformer: true,
  34. setMetaFromTargetForm: true,
  35. target: '.MyForm',
  36. locale: {
  37. strings: { browse: 'wow' }
  38. }
  39. })
  40. .use(GoogleDrive, {target: Dashboard, host: 'http://localhost:3020'})
  41. .use(Dropbox, {target: Dashboard, host: 'http://localhost:3020'})
  42. .use(GoogleDrive, {target: Dashboard, host: 'http://localhost:3020'})
  43. .use(Dropbox, {target: Dashboard, host: 'http://localhost:3020'})
  44. .use(Instagram, {target: Dashboard, host: 'http://localhost:3020'})
  45. // .use(FileInput, {target: '.Uppy', locale: {
  46. // strings: {selectToUpload: 'Выберите файл для загрузки'}
  47. // }})
  48. // .use(DragDrop, {target: 'body', locale: {
  49. // strings: {chooseFile: 'Выберите файл'}
  50. // }})
  51. // .use(ProgressBar, {target: 'body'})
  52. // .use(Webcam, {target: Dashboard})
  53. // .use(Multipart, {endpoint: '//api2.transloadit.com'})
  54. .use(Tus10, {endpoint: TUS_ENDPOINT, resume: true})
  55. // .use(Informer, {target: Dashboard})
  56. // .use(StatusBar, {target: Dashboard})
  57. .use(MetaData, {
  58. fields: [
  59. { id: 'resizeTo', name: 'Resize to', value: 1200, placeholder: 'specify future image size' },
  60. { id: 'description', name: 'Description', value: 'none', placeholder: 'describe what the file is for' }
  61. ]
  62. })
  63. uppy.run()
  64. uppy.on('core:success', (fileCount) => {
  65. console.log('UPLOAD SUCCESSFUL!!!')
  66. console.log(fileCount)
  67. })
  68. // uppy.emit('informer', 'Smile!', 'info', 2000)
  69. var modalTrigger = document.querySelector('#uppyModalOpener')
  70. if (modalTrigger) modalTrigger.click()