diff --git a/apps/files/src/FileUpload.js b/apps/files/src/FileUpload.js deleted file mode 100644 index 176fd533d8d..00000000000 --- a/apps/files/src/FileUpload.js +++ /dev/null @@ -1,61 +0,0 @@ -class FileUpload { - constructor (file, path, url, headers = {}, onProgress = () => {}, type = 'POST', onUploadEnded = () => {}) { - this.file = file - this.path = path - this.url = url - this.headers = headers - this.onProgress = onProgress - this.type = type - this.onUploadEnded = onUploadEnded - } - - upload (options = {}) { - const xhr = new XMLHttpRequest() - - // Headers - this.path = this.path.replace(/(^\/+)/, '') - let paths = this.path.split('/') - paths = paths.map(path => encodeURIComponent(path)) - this.path = paths.join('/') - xhr.open(this.type, this.url + this.path, true) - xhr.responseType = 'text' - if (options.overwrite) { - this.headers['If-Match'] = options.overwrite - delete this.headers['If-None-Match'] - } else { - this.headers['If-None-Match'] = '*' - delete this.headers['If-Match'] - } - this._setXhrHeaders(xhr) - - // Events - xhr.upload.addEventListener('progress', (e) => { - this.onProgress(e, this.file) - }, false) - - const promise = new Promise((resolve, reject) => { - xhr.onload = e => { - xhr.status >= 200 && xhr.status < 400 ? resolve(e) : reject(new Error(xhr.statusText)) - } - xhr.onloadend = e => { - this.onUploadEnded(this.file) - } - xhr.onerror = e => { - reject(e) - } - }) - - // Start upload - xhr.send(this.file) - - return promise - } - - _setXhrHeaders (xhr) { - Object.keys(this.headers).forEach(p => - xhr.setRequestHeader(p, this.headers[p]) - ) - } -} - -export default FileUpload diff --git a/apps/files/src/components/FileDrop.vue b/apps/files/src/components/FileDrop.vue index 7e15f6cddcb..549a50c2b9e 100644 --- a/apps/files/src/components/FileDrop.vue +++ b/apps/files/src/components/FileDrop.vue @@ -30,7 +30,7 @@ export default { }, props: { rootPath: { type: String, required: true }, - url: { type: String, required: true }, + path: { type: String, required: true }, headers: { type: Object, default: () => { @@ -45,7 +45,7 @@ export default { data () { return { ocDropzone_options: { - url: this.url, + url: '#', // FIXME: unused clickable: false, autoQueue: false } diff --git a/apps/files/src/components/FileUpload.vue b/apps/files/src/components/FileUpload.vue index df66c52b593..5e2bfc68d4e 100644 --- a/apps/files/src/components/FileUpload.vue +++ b/apps/files/src/components/FileUpload.vue @@ -12,7 +12,7 @@ import Mixins from '../mixins' export default { props: { - url: { type: String, required: true }, + path: { type: String, required: true }, headers: { type: Object, default: () => { diff --git a/apps/files/src/components/FilesAppBar.vue b/apps/files/src/components/FilesAppBar.vue index afc36a94ad1..e35906d0fa8 100644 --- a/apps/files/src/components/FilesAppBar.vue +++ b/apps/files/src/components/FilesAppBar.vue @@ -1,6 +1,6 @@