From 7569035be02d682df2f8d29c1394902cdf64c5a6 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 2 Jun 2020 12:08:34 +0200 Subject: [PATCH] Use chunk size and method override from caps Use the chunk size from the capabilities if it is higher than the locally configured one. Use HTTP method override mode if the TUS capabilities says so. --- apps/files/src/mixins.js | 13 ++++++++++++- changelog/unreleased/3568 | 11 +++++++++++ src/plugins/upload.js | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/3568 diff --git a/apps/files/src/mixins.js b/apps/files/src/mixins.js index bc03e6b75d8..af11beb84e1 100644 --- a/apps/files/src/mixins.js +++ b/apps/files/src/mixins.js @@ -447,9 +447,20 @@ export default { // FIXME: this might break if relativePath is not the currentFolder // and is a mount point that has no chunk support if (this.browserSupportsChunked && this.currentFolder.isChunkedUploadSupported) { + let chunkSize = this.configuration.uploadChunkSize + if (this.capabilities.files.tus_support.max_chunk_size > 0) { + if ( + chunkSize === null || + chunkSize === 0 || + chunkSize > this.capabilities.files.tus_support.max_chunk_size + ) { + chunkSize = this.capabilities.files.tus_support.max_chunk_size + } + } promise = this.uploadQueue.add(() => { return this.uploadChunkedFile(file, pathUtil.dirname(relativePath), { - chunkSize: this.configuration.uploadChunkSize, + chunkSize: chunkSize, + overridePatchMethod: !!this.capabilities.files.tus_support.http_method_override, emitProgress: progress => { this.$_ocUpload_onProgress(progress, file) } diff --git a/changelog/unreleased/3568 b/changelog/unreleased/3568 new file mode 100644 index 00000000000..55f66277edb --- /dev/null +++ b/changelog/unreleased/3568 @@ -0,0 +1,11 @@ +Enhancement: Use TUS settings from capabilities + +The TUS settings advertise the maximum chunk size, so we now use the smallest chunk size from +the one configured in config.json and the one from the capabilities. + +If the capabilities report that one should use the X-HTTP-Override-Method header, +the upload will now use a POST request for uploads with that header set +instead of PATCH. + +https://github.com/owncloud/ocis-reva/issues/177 +https://github.com/owncloud/phoenix/pull/3568 diff --git a/src/plugins/upload.js b/src/plugins/upload.js index c1b4a5052a4..47253e770f3 100644 --- a/src/plugins/upload.js +++ b/src/plugins/upload.js @@ -25,6 +25,7 @@ export default { headers: headers, chunkSize: options.chunkSize || Infinity, removeFingerprintOnSuccess: true, + overridePatchMethod: !!options.overridePatchMethod, retryDelays: [0, 3000, 5000, 10000, 20000], metadata: { filename: file.name,