Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const token = file.serverToken
const host = getSocketHost(file.remote.companionUrl)
const socket = new Socket({ target: `${host}/api/${token}`, autoOpen: false })
this.uploaderSockets[file.id] = socket
this.uploaderEvents[file.id] = new EventTracker(this.uppy)
this.onFileRemove(file.id, () => {
queuedRequest.abort()
socket.send('pause', {})
this.resetUploaderReferences(file.id)
resolve(`upload ${file.id} was removed`)
})
this.onPause(file.id, (isPaused) => {
if (isPaused) {
// Remove this file from the queue so another file can start in its place.
queuedRequest.abort()
socket.send('pause', {})
} else {
}).then((res) => {
const token = res.token
const host = getSocketHost(file.remote.companionUrl)
const socket = new Socket({ target: `${host}/api/${token}`, autoOpen: false })
this.uploaderEvents[file.id] = new EventTracker(this.uppy)
this.onFileRemove(file.id, () => {
socket.send('pause', {})
queuedRequest.abort()
resolve(`upload ${file.id} was removed`)
})
this.onCancelAll(file.id, () => {
socket.send('pause', {})
queuedRequest.abort()
resolve(`upload ${file.id} was canceled`)
})
this.onRetry(file.id, () => {
socket.send('pause', {})
return new Promise((resolve, reject) => {
const token = file.serverToken
const host = getSocketHost(file.remote.companionUrl)
const socket = new Socket({ target: `${host}/api/${token}` })
this.uploaderSockets[socket] = socket
this.uploaderEvents[file.id] = createEventTracker(this.uppy)
this.onFileRemove(file.id, (removed) => {
this.resetUploaderReferences(file.id, { abort: true })
resolve(`upload ${file.id} was removed`)
})
this.onFilePause(file.id, (isPaused) => {
socket.send(isPaused ? 'pause' : 'resume', {})
})
this.onPauseAll(file.id, () => socket.send('pause', {}))
this.onResumeAll(file.id, () => {
if (file.error) {