From dd3a6d294139a0a243d625b629530fe2a0f5c262 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Mon, 21 Oct 2024 17:58:41 +0200 Subject: [PATCH] allow for all upload protocols seems to be working closes #5305 --- docs/companion.md | 6 ++++-- packages/@uppy/companion/src/server/Uploader.js | 8 ++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/companion.md b/docs/companion.md index e3c6a41360..6468b4f652 100644 --- a/docs/companion.md +++ b/docs/companion.md @@ -643,8 +643,10 @@ fully downloaded first, then uploaded. Defaults to `true`. A boolean flag to tell Companion whether to also upload files that have an unknown size. Currently this is only supported for Tus uploads. Note that this -requires an optional extension on the Tus server. Default is `false`. If set to -`true`, `streamingUpload` has to be also set to `true`. +requires an optional extension on the Tus server if using Tus uploads. For form +multipart uploads it requres a server that can handle +`transfer-encoding: chunked`. Default is `false`. If set to `true`, +`streamingUpload` also has to be set to `true`. #### `maxFileSize` `COMPANION_MAX_FILE_SIZE` diff --git a/packages/@uppy/companion/src/server/Uploader.js b/packages/@uppy/companion/src/server/Uploader.js index 773ff41cbd..c1bf7ba250 100644 --- a/packages/@uppy/companion/src/server/Uploader.js +++ b/packages/@uppy/companion/src/server/Uploader.js @@ -269,14 +269,10 @@ class Uploader { } _canStream() { - const protocol = this._getUploadProtocol() - return this.options.companionOptions.streamingUpload && ( this.options.size // only tus uploads can be streamed without size, TODO: add also others - || (this.options.companionOptions.streamingUploadSizeless && ( - protocol === PROTOCOLS.tus - )) + || this.options.companionOptions.streamingUploadSizeless ) } @@ -619,7 +615,7 @@ class Uploader { const response = await runRequest(url, reqOptions) - if (bytesUploaded !== this.size) { + if (this.size != null && bytesUploaded !== this.size) { const errMsg = `uploaded only ${bytesUploaded} of ${this.size} with status: ${response.statusCode}` logger.error(errMsg, 'upload.multipart.mismatch.error') throw new Error(errMsg)