Skip to content

Commit

Permalink
Use chunk size and method override from caps
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Vincent Petry committed Jun 2, 2020
1 parent 049af2a commit 1b852fb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
15 changes: 14 additions & 1 deletion apps/files/src/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,22 @@ 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
}
}
console.log('tus_support: ', this.capabilities.files.tus_support)
console.log('Using chunk size: ', chunkSize)
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 1b852fb

Please sign in to comment.