Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make deferred upload length optional #5561

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@uppy/companion/KUBERNETES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ data:
COMPANION_DOMAINS: 'sub1.domain.com,sub2.domain.com,sub3.domain.com'
COMPANION_PROTOCOL: 'YOUR SERVER PROTOCOL'
COMPANION_STREAMING_UPLOAD: true
COMPANION_DEFERRED_UPLOAD_LENGTH: true
COMPANION_REDIS_URL: redis://:superSecretPassword@uppy-redis.uppy.svc.cluster.local:6379
COMPANION_SECRET: 'shh!Issa Secret!'
COMPANION_PREAUTH_SECRET: 'another secret'
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/companion/env_example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ COMPANION_SELF_ENDPOINT=uppy.xxxx.com
COMPANION_HIDE_METRICS=false
COMPANION_HIDE_WELCOME=false
COMPANION_STREAMING_UPLOAD=true
COMPANION_DEFERRED_UPLOAD_LENGTH=true

COMPANION_PROTOCOL=https
COMPANION_DATADIR=/mnt/uppy-server-data
Expand Down
9 changes: 7 additions & 2 deletions packages/@uppy/companion/src/server/Uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,7 @@ class Uploader {
const tusOptions = {
endpoint: this.options.endpoint,
uploadUrl: this.options.uploadUrl,
uploadLengthDeferred: !isFileStream,
retryDelays: [0, 1000, 3000, 5000],
uploadSize: isFileStream ? this.size : undefined,
chunkSize,
headers: headerSanitize(this.options.headers),
addRequestId: true,
Expand Down Expand Up @@ -553,6 +551,13 @@ class Uploader {
},
}

if (this.options.companionOptions.deferredUploadLength && !isFileStream) {
tusOptions.uploadLengthDeferred = true
} else {
tusOptions.uploadLengthDeferred = false
tusOptions.uploadSize = this.size
}

this.tus = new tus.Upload(stream, tusOptions)

this.tus.start()
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/companion/src/standalone/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const getConfigFromEnv = () => {
// cookieDomain is kind of a hack to support distributed systems. This should be improved but we never got so far.
cookieDomain: process.env.COMPANION_COOKIE_DOMAIN,
streamingUpload: process.env.COMPANION_STREAMING_UPLOAD ? process.env.COMPANION_STREAMING_UPLOAD === 'true' : undefined,
deferredUploadLength: process.env.COMPANION_DEFERRED_UPLOAD_LENGTH ? process.env.COMPANION_DEFERRED_UPLOAD_LENGTH === 'true' : true,
maxFileSize: process.env.COMPANION_MAX_FILE_SIZE ? parseInt(process.env.COMPANION_MAX_FILE_SIZE, 10) : undefined,
chunkSize: process.env.COMPANION_CHUNK_SIZE ? parseInt(process.env.COMPANION_CHUNK_SIZE, 10) : undefined,
clientSocketConnectTimeout: process.env.COMPANION_CLIENT_SOCKET_CONNECT_TIMEOUT
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/companion/test/mockserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const defaultEnv = {
COMPANION_HIDE_WELCOME: 'false',

COMPANION_STREAMING_UPLOAD: 'true',
COMPANION_DEFERRED_UPLOAD_LENGTH: 'true',
COMPANION_ALLOW_LOCAL_URLS: 'false',

COMPANION_PROTOCOL: 'http',
Expand Down
Loading