Skip to content

Commit

Permalink
allow for all upload protocols
Browse files Browse the repository at this point in the history
seems to be working
closes #5305
  • Loading branch information
mifi committed Oct 21, 2024
1 parent 0f34fda commit dd3a6d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 4 additions & 2 deletions docs/companion.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
8 changes: 2 additions & 6 deletions packages/@uppy/companion/src/server/Uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dd3a6d2

Please sign in to comment.