Skip to content
Snippets Groups Projects
Select Git revision
  • develop default protected
  • master
  • 1121-download
  • plugins-v3
  • 876-http-signature
  • plugins-v2
  • plugins
  • 0.21.2
  • 0.21.1
  • 0.21
  • 0.21-rc2
  • 0.21-rc1
  • 0.20.1
  • 0.20.0
  • 0.20.0-rc1
  • 0.19.1
  • 0.19.0
  • 0.19.0-rc2
  • 0.19.0-rc1
  • 0.18.3
  • 0.18.2
  • 0.18.1
  • 0.18
  • 0.17
  • 0.16.3
  • 0.16.2
  • 0.16.1
27 results

FileUploadWidget.vue

Blame
  • Forked from funkwhale / funkwhale
    6150 commits behind the upstream repository.
    FileUploadWidget.vue 1.07 KiB
    <script>
    import FileUpload from 'vue-upload-component'
    
    export default {
      extends: FileUpload,
      methods: {
        uploadHtml5 (file) {
          let form = new window.FormData()
          let value
          for (let key in file.data) {
            value = file.data[key]
            if (value && typeof value === 'object' && typeof value.toString !== 'function') {
              if (value instanceof File) {
                form.append(key, value, value.name)
              } else {
                form.append(key, JSON.stringify(value))
              }
            } else if (value !== null && value !== undefined) {
              form.append(key, value)
            }
          }
          let filename = file.file.filename || file.name
          form.append('source', `upload://${filename}`)
          form.append(this.name, file.file, filename)
          let xhr = new XMLHttpRequest()
          xhr.open('POST', file.postAction)
          xhr.setRequestHeader('Authorization', this.$store.getters['auth/header'])
          return this.uploadXhr(xhr, file, form)
        }
      }
    }
    </script>
    
    <!-- Add "scoped" attribute to limit CSS to this component only -->
    <style scoped>
    </style>