Skip to content

Commit

Permalink
Merge pull request #3568 from owncloud/tus-use-capability-values
Browse files Browse the repository at this point in the history
Use chunk size and method override from caps
  • Loading branch information
Vincent Petry authored Jun 3, 2020
2 parents 049af2a + 7569035 commit 7790e57
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
13 changes: 12 additions & 1 deletion apps/files/src/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
11 changes: 11 additions & 0 deletions changelog/unreleased/3568
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/plugins/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7790e57

Please sign in to comment.