main.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const transloadit = require('@uppy/transloadit-preset')
  2. /**
  3. * transloadit.form
  4. */
  5. window.formUppy = transloadit.form('#test-form', {
  6. debug: true,
  7. restrictions: {
  8. allowedFileTypes: ['.png']
  9. },
  10. waitForEncoding: true,
  11. params: {
  12. auth: { key: '05a61ed019fe11e783fdbd1f56c73eb0' },
  13. template_id: 'be001500a56011e889f9cddd88df842c'
  14. }
  15. })
  16. /**
  17. * transloadit.modal
  18. */
  19. function openModal () {
  20. transloadit.modal('body', {
  21. restrictions: {
  22. allowedFileTypes: ['.png']
  23. },
  24. waitForEncoding: true,
  25. params: {
  26. auth: { key: '05a61ed019fe11e783fdbd1f56c73eb0' },
  27. template_id: 'be001500a56011e889f9cddd88df842c'
  28. },
  29. providers: [
  30. 'webcam'
  31. ]
  32. // if providers need custom config
  33. // webcam: {
  34. // option: 'whatever'
  35. // }
  36. }).then(console.log, console.error)
  37. }
  38. window.openModal = openModal
  39. /**
  40. * transloadit.upload
  41. */
  42. window.doUpload = (event) => {
  43. transloadit.upload(event.target.files, {
  44. waitForEncoding: true,
  45. params: {
  46. auth: { key: '05a61ed019fe11e783fdbd1f56c73eb0' },
  47. template_id: 'be001500a56011e889f9cddd88df842c'
  48. }
  49. }).then(console.log, console.error)
  50. }