You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.3 KiB

  1. <template>
  2. <file-pond
  3. ref="pond"
  4. chunk-uploads="true"
  5. label-idle="Drop files here..."
  6. :allow-multiple="false"
  7. :server="server"
  8. :files="myFiles"
  9. @processfile="handleFilePondProcessfile"
  10. @removefile="handleFilePondRemovefile"
  11. />
  12. </template>
  13. <script>
  14. import Cookies from 'js-cookie'
  15. import vueFilePond from "vue-filepond"
  16. import "filepond/dist/filepond.min.css"
  17. import FilePondPluginFileValidateType from "filepond-plugin-file-validate-type"
  18. const FilePond = vueFilePond(
  19. FilePondPluginFileValidateType,
  20. )
  21. export default {
  22. components: {
  23. FilePond,
  24. },
  25. props: {
  26. value: {
  27. type: String,
  28. default: '',
  29. required: true
  30. }
  31. },
  32. data() {
  33. return {
  34. myFiles: [],
  35. server: {
  36. url: '/v1/fp',
  37. headers: {
  38. 'X-CSRFToken': Cookies.get('csrftoken'),
  39. },
  40. process: {
  41. url: '/process/',
  42. method: 'POST',
  43. },
  44. patch: '/patch/',
  45. revert: '/revert/',
  46. restore: '/restore/',
  47. load: '/load/',
  48. fetch: '/fetch/'
  49. }
  50. }
  51. },
  52. methods: {
  53. handleFilePondProcessfile(error, file) {
  54. console.log(error)
  55. this.$emit('input', file.serverId)
  56. },
  57. handleFilePondRemovefile() {
  58. this.$emit('input', '')
  59. }
  60. },
  61. };
  62. </script>