|
@@ -25,7 +25,7 @@ const TL_COMPANION = /https?:\/\/api2(?:-\w+)?\.transloadit\.com\/companion/
|
|
|
* Upload files to Transloadit using Tus.
|
|
|
*/
|
|
|
module.exports = class Transloadit extends BasePlugin {
|
|
|
- static VERSION = require('../package.json').version
|
|
|
+ static VERSION = require('../package.json').version // eslint-disable-line global-require
|
|
|
|
|
|
constructor (uppy, opts) {
|
|
|
super(uppy, opts)
|
|
@@ -59,15 +59,6 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
|
|
|
this.i18nInit()
|
|
|
|
|
|
- this._prepareUpload = this._prepareUpload.bind(this)
|
|
|
- this._afterUpload = this._afterUpload.bind(this)
|
|
|
- this._onError = this._onError.bind(this)
|
|
|
- this._onTusError = this._onTusError.bind(this)
|
|
|
- this._onCancelAll = this._onCancelAll.bind(this)
|
|
|
- this._onFileUploadURLAvailable = this._onFileUploadURLAvailable.bind(this)
|
|
|
- this._onRestored = this._onRestored.bind(this)
|
|
|
- this._getPersistentData = this._getPersistentData.bind(this)
|
|
|
-
|
|
|
const hasCustomAssemblyOptions = this.opts.getAssemblyOptions !== defaultOptions.getAssemblyOptions
|
|
|
if (this.opts.params) {
|
|
|
AssemblyOptions.validateParams(this.opts.params)
|
|
@@ -79,14 +70,15 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
|
|
|
this.client = new Client({
|
|
|
service: this.opts.service,
|
|
|
- client: this._getClientVersion(),
|
|
|
+ client: this.#getClientVersion(),
|
|
|
errorReporting: this.opts.errorReporting,
|
|
|
})
|
|
|
// Contains Assembly instances for in-progress Assemblies.
|
|
|
this.activeAssemblies = {}
|
|
|
// Contains a mapping of uploadID to AssemblyWatcher
|
|
|
this.assemblyWatchers = {}
|
|
|
- // Contains a file IDs that have completed postprocessing before the upload they belong to has entered the postprocess stage.
|
|
|
+ // Contains a file IDs that have completed postprocessing before the upload
|
|
|
+ // they belong to has entered the postprocess stage.
|
|
|
this.completedFiles = Object.create(null)
|
|
|
}
|
|
|
|
|
@@ -102,7 +94,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
this.setPluginState() // so that UI re-renders and we see the updated locale
|
|
|
}
|
|
|
|
|
|
- _getClientVersion () {
|
|
|
+ #getClientVersion () {
|
|
|
const list = [
|
|
|
`uppy-core:${this.uppy.constructor.VERSION}`,
|
|
|
`uppy-transloadit:${this.constructor.VERSION}`,
|
|
@@ -143,7 +135,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
* @param {object} file
|
|
|
* @param {object} status
|
|
|
*/
|
|
|
- _attachAssemblyMetadata (file, status) {
|
|
|
+ #attachAssemblyMetadata (file, status) {
|
|
|
// Add the metadata parameters Transloadit needs.
|
|
|
const meta = {
|
|
|
...file.meta,
|
|
@@ -193,7 +185,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
return newFile
|
|
|
}
|
|
|
|
|
|
- _createAssembly (fileIDs, uploadID, options) {
|
|
|
+ #createAssembly (fileIDs, uploadID, options) {
|
|
|
this.uppy.log('[Transloadit] Create Assembly')
|
|
|
|
|
|
return this.client.createAssembly({
|
|
@@ -226,7 +218,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
const { files } = this.uppy.getState()
|
|
|
const updatedFiles = {}
|
|
|
fileIDs.forEach((id) => {
|
|
|
- updatedFiles[id] = this._attachAssemblyMetadata(this.uppy.getFile(id), status)
|
|
|
+ updatedFiles[id] = this.#attachAssemblyMetadata(this.uppy.getFile(id), status)
|
|
|
})
|
|
|
this.uppy.setState({
|
|
|
files: {
|
|
@@ -240,13 +232,14 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
this.uppy.log(`[Transloadit] Created Assembly ${assemblyID}`)
|
|
|
return assembly
|
|
|
}).catch((err) => {
|
|
|
- err.message = `${this.i18n('creatingAssemblyFailed')}: ${err.message}`
|
|
|
+ const error = new Error(`${this.i18n('creatingAssemblyFailed')}: ${err.message}`)
|
|
|
+ error.cause = err
|
|
|
// Reject the promise.
|
|
|
- throw err
|
|
|
+ throw error
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- _createAssemblyWatcher (assemblyID, fileIDs, uploadID) {
|
|
|
+ #createAssemblyWatcher (assemblyID, fileIDs, uploadID) {
|
|
|
// AssemblyWatcher tracks completion states of all Assemblies in this upload.
|
|
|
const watcher = new AssemblyWatcher(this.uppy, assemblyID)
|
|
|
|
|
@@ -272,7 +265,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
this.assemblyWatchers[uploadID] = watcher
|
|
|
}
|
|
|
|
|
|
- _shouldWaitAfterUpload () {
|
|
|
+ #shouldWaitAfterUpload () {
|
|
|
return this.opts.waitForEncoding || this.opts.waitForMetadata
|
|
|
}
|
|
|
|
|
@@ -280,7 +273,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
* Used when `importFromUploadURLs` is enabled: reserves all files in
|
|
|
* the Assembly.
|
|
|
*/
|
|
|
- _reserveFiles (assembly, fileIDs) {
|
|
|
+ #reserveFiles (assembly, fileIDs) {
|
|
|
return Promise.all(fileIDs.map((fileID) => {
|
|
|
const file = this.uppy.getFile(fileID)
|
|
|
return this.client.reserveFile(assembly.status, file)
|
|
@@ -291,7 +284,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
* Used when `importFromUploadURLs` is enabled: adds files to the Assembly
|
|
|
* once they have been fully uploaded.
|
|
|
*/
|
|
|
- _onFileUploadURLAvailable (rawFile) {
|
|
|
+ #onFileUploadURLAvailable =(rawFile) => {
|
|
|
const file = this.uppy.getFile(rawFile.id)
|
|
|
if (!file || !file.transloadit || !file.transloadit.assembly) {
|
|
|
return
|
|
@@ -306,7 +299,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- _findFile (uploadedFile) {
|
|
|
+ #findFile (uploadedFile) {
|
|
|
const files = this.uppy.getFiles()
|
|
|
for (let i = 0; i < files.length; i++) {
|
|
|
const file = files[i]
|
|
@@ -325,11 +318,12 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return undefined
|
|
|
}
|
|
|
|
|
|
- _onFileUploadComplete (assemblyId, uploadedFile) {
|
|
|
+ #onFileUploadComplete (assemblyId, uploadedFile) {
|
|
|
const state = this.getPluginState()
|
|
|
- const file = this._findFile(uploadedFile)
|
|
|
+ const file = this.#findFile(uploadedFile)
|
|
|
if (!file) {
|
|
|
this.uppy.log('[Transloadit] Couldn’t file the file, it was likely removed in the process')
|
|
|
return
|
|
@@ -354,11 +348,11 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
* @param {string} stepName
|
|
|
* @param {object} result
|
|
|
*/
|
|
|
- _onResult (assemblyId, stepName, result) {
|
|
|
+ #onResult (assemblyId, stepName, result) {
|
|
|
const state = this.getPluginState()
|
|
|
const file = state.files[result.original_id]
|
|
|
// The `file` may not exist if an import robot was used instead of a file upload.
|
|
|
- result.localId = file ? file.id : null
|
|
|
+ result.localId = file ? file.id : null // eslint-disable-line no-param-reassign
|
|
|
|
|
|
const entry = {
|
|
|
result,
|
|
@@ -379,7 +373,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
*
|
|
|
* @param {object} status
|
|
|
*/
|
|
|
- _onAssemblyFinished (status) {
|
|
|
+ #onAssemblyFinished (status) {
|
|
|
const url = status.assembly_ssl_url
|
|
|
this.client.getAssemblyStatus(url).then((finalStatus) => {
|
|
|
const assemblyId = finalStatus.assembly_id
|
|
@@ -394,24 +388,23 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- _cancelAssembly (assembly) {
|
|
|
- return this.client.cancelAssembly(assembly).then(() => {
|
|
|
- // TODO bubble this through AssemblyWatcher so its event handlers can clean up correctly
|
|
|
- this.uppy.emit('transloadit:assembly-cancelled', assembly)
|
|
|
- })
|
|
|
+ async #cancelAssembly (assembly) {
|
|
|
+ await this.client.cancelAssembly(assembly)
|
|
|
+ // TODO bubble this through AssemblyWatcher so its event handlers can clean up correctly
|
|
|
+ this.uppy.emit('transloadit:assembly-cancelled', assembly)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* When all files are removed, cancel in-progress Assemblies.
|
|
|
*/
|
|
|
- _onCancelAll () {
|
|
|
+ #onCancelAll =() => {
|
|
|
const { uploadsAssemblies } = this.getPluginState()
|
|
|
|
|
|
const assemblyIDs = Object.values(uploadsAssemblies)
|
|
|
|
|
|
const cancelPromises = assemblyIDs.map((assemblyID) => {
|
|
|
const assembly = this.getAssembly(assemblyID)
|
|
|
- return this._cancelAssembly(assembly)
|
|
|
+ return this.#cancelAssembly(assembly)
|
|
|
})
|
|
|
|
|
|
Promise.all(cancelPromises).catch((err) => {
|
|
@@ -425,7 +418,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
*
|
|
|
* @param {Function} setData
|
|
|
*/
|
|
|
- _getPersistentData (setData) {
|
|
|
+ #getPersistentData =(setData) => {
|
|
|
const state = this.getPluginState()
|
|
|
const { assemblies } = state
|
|
|
const { uploadsAssemblies } = state
|
|
@@ -438,7 +431,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- _onRestored (pluginData) {
|
|
|
+ #onRestored =(pluginData) => {
|
|
|
const savedState = pluginData && pluginData[this.id] ? pluginData[this.id] : {}
|
|
|
const previousAssemblies = savedState.assemblies || {}
|
|
|
const uploadsAssemblies = savedState.uploadsAssemblies || {}
|
|
@@ -452,11 +445,9 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
const restoreState = (assemblies) => {
|
|
|
const files = {}
|
|
|
const results = []
|
|
|
- Object.keys(assemblies).forEach((id) => {
|
|
|
- const status = assemblies[id]
|
|
|
-
|
|
|
+ for (const [id, status] of Object.entries(assemblies)) {
|
|
|
status.uploads.forEach((uploadedFile) => {
|
|
|
- const file = this._findFile(uploadedFile)
|
|
|
+ const file = this.#findFile(uploadedFile)
|
|
|
files[uploadedFile.id] = {
|
|
|
id: file.id,
|
|
|
assembly: id,
|
|
@@ -466,7 +457,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
|
|
|
const state = this.getPluginState()
|
|
|
Object.keys(status.results).forEach((stepName) => {
|
|
|
- status.results[stepName].forEach((result) => {
|
|
|
+ for (const result of status.results[stepName]) {
|
|
|
const file = state.files[result.original_id]
|
|
|
result.localId = file ? file.id : null
|
|
|
results.push({
|
|
@@ -475,9 +466,9 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
stepName,
|
|
|
assembly: id,
|
|
|
})
|
|
|
- })
|
|
|
+ }
|
|
|
})
|
|
|
- })
|
|
|
+ }
|
|
|
|
|
|
this.setPluginState({
|
|
|
assemblies,
|
|
@@ -489,6 +480,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
|
|
|
// Set up the Assembly instances and AssemblyWatchers for existing Assemblies.
|
|
|
const restoreAssemblies = () => {
|
|
|
+ // eslint-disable-next-line no-shadow
|
|
|
const { assemblies, uploadsAssemblies } = this.getPluginState()
|
|
|
|
|
|
// Set up the assembly watchers again for all the ongoing uploads.
|
|
@@ -499,13 +491,13 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
acc.push(...fileIDsInAssembly)
|
|
|
return acc
|
|
|
}, [])
|
|
|
- this._createAssemblyWatcher(assemblyIDs, fileIDsInUpload, uploadID)
|
|
|
+ this.#createAssemblyWatcher(assemblyIDs, fileIDsInUpload, uploadID)
|
|
|
})
|
|
|
|
|
|
const allAssemblyIDs = Object.keys(assemblies)
|
|
|
allAssemblyIDs.forEach((id) => {
|
|
|
const assembly = new Assembly(assemblies[id])
|
|
|
- this._connectAssembly(assembly)
|
|
|
+ this.#connectAssembly(assembly)
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -531,7 +523,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- _connectAssembly (assembly) {
|
|
|
+ #connectAssembly (assembly) {
|
|
|
const { status } = assembly
|
|
|
const id = status.assembly_id
|
|
|
this.activeAssemblies[id] = assembly
|
|
@@ -548,10 +540,10 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
})
|
|
|
|
|
|
assembly.on('upload', (file) => {
|
|
|
- this._onFileUploadComplete(id, file)
|
|
|
+ this.#onFileUploadComplete(id, file)
|
|
|
})
|
|
|
assembly.on('error', (error) => {
|
|
|
- error.assembly = assembly.status
|
|
|
+ error.assembly = assembly.status // eslint-disable-line no-param-reassign
|
|
|
this.uppy.emit('transloadit:assembly-error', assembly.status, error)
|
|
|
})
|
|
|
|
|
@@ -561,17 +553,17 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
|
|
|
if (this.opts.waitForEncoding) {
|
|
|
assembly.on('result', (stepName, result) => {
|
|
|
- this._onResult(id, stepName, result)
|
|
|
+ this.#onResult(id, stepName, result)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
if (this.opts.waitForEncoding) {
|
|
|
assembly.on('finished', () => {
|
|
|
- this._onAssemblyFinished(assembly.status)
|
|
|
+ this.#onAssemblyFinished(assembly.status)
|
|
|
})
|
|
|
} else if (this.opts.waitForMetadata) {
|
|
|
assembly.on('metadata', () => {
|
|
|
- this._onAssemblyFinished(assembly.status)
|
|
|
+ this.#onAssemblyFinished(assembly.status)
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -584,32 +576,32 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
return assembly
|
|
|
}
|
|
|
|
|
|
- _prepareUpload (fileIDs, uploadID) {
|
|
|
+ #prepareUpload = (fileIDs, uploadID) => {
|
|
|
// Only use files without errors
|
|
|
- fileIDs = fileIDs.filter((file) => !file.error)
|
|
|
+ const filteredFileIDs = fileIDs.filter((file) => !file.error)
|
|
|
|
|
|
- fileIDs.forEach((fileID) => {
|
|
|
+ const files = filteredFileIDs.map(fileID => {
|
|
|
const file = this.uppy.getFile(fileID)
|
|
|
this.uppy.emit('preprocess-progress', file, {
|
|
|
mode: 'indeterminate',
|
|
|
message: this.i18n('creatingAssembly'),
|
|
|
})
|
|
|
+ return file
|
|
|
})
|
|
|
|
|
|
- const createAssembly = ({ fileIDs, options }) => {
|
|
|
- let createdAssembly
|
|
|
- return this._createAssembly(fileIDs, uploadID, options).then((assembly) => {
|
|
|
- createdAssembly = assembly
|
|
|
+ // eslint-disable-next-line no-shadow
|
|
|
+ const createAssembly = async ({ fileIDs, options }) => {
|
|
|
+ try {
|
|
|
+ const assembly = await this.#createAssembly(fileIDs, uploadID, options)
|
|
|
if (this.opts.importFromUploadURLs) {
|
|
|
- return this._reserveFiles(assembly, fileIDs)
|
|
|
+ await this.#reserveFiles(assembly, fileIDs)
|
|
|
}
|
|
|
- }).then(() => {
|
|
|
fileIDs.forEach((fileID) => {
|
|
|
const file = this.uppy.getFile(fileID)
|
|
|
this.uppy.emit('preprocess-complete', file)
|
|
|
})
|
|
|
- return createdAssembly
|
|
|
- }).catch((err) => {
|
|
|
+ return assembly
|
|
|
+ } catch (err) {
|
|
|
fileIDs.forEach((fileID) => {
|
|
|
const file = this.uppy.getFile(fileID)
|
|
|
// Clear preprocessing state when the Assembly could not be created,
|
|
@@ -618,7 +610,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
this.uppy.emit('upload-error', file, err)
|
|
|
})
|
|
|
throw err
|
|
|
- })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const { uploadsAssemblies } = this.getPluginState()
|
|
@@ -629,21 +621,19 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
},
|
|
|
})
|
|
|
|
|
|
- const files = fileIDs.map((id) => this.uppy.getFile(id))
|
|
|
const assemblyOptions = new AssemblyOptions(files, this.opts)
|
|
|
|
|
|
return assemblyOptions.build()
|
|
|
.then((assemblies) => Promise.all(assemblies.map(createAssembly)))
|
|
|
.then((createdAssemblies) => {
|
|
|
const assemblyIDs = createdAssemblies.map(assembly => assembly.status.assembly_id)
|
|
|
- this._createAssemblyWatcher(assemblyIDs, fileIDs, uploadID)
|
|
|
- return Promise.all(createdAssemblies.map(assembly => this._connectAssembly(assembly)))
|
|
|
+ this.#createAssemblyWatcher(assemblyIDs, filteredFileIDs, uploadID)
|
|
|
+ return Promise.all(createdAssemblies.map(assembly => this.#connectAssembly(assembly)))
|
|
|
})
|
|
|
// If something went wrong before any Assemblies could be created,
|
|
|
// clear all processing state.
|
|
|
.catch((err) => {
|
|
|
- fileIDs.forEach((fileID) => {
|
|
|
- const file = this.uppy.getFile(fileID)
|
|
|
+ files.forEach((file) => {
|
|
|
this.uppy.emit('preprocess-complete', file)
|
|
|
this.uppy.emit('upload-error', file, err)
|
|
|
})
|
|
@@ -651,17 +641,17 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- _afterUpload (fileIDs, uploadID) {
|
|
|
+ #afterUpload =(fileIDs, uploadID) => {
|
|
|
const files = fileIDs.map(fileID => this.uppy.getFile(fileID))
|
|
|
// Only use files without errors
|
|
|
- fileIDs = files.filter((file) => !file.error).map(file => file.id)
|
|
|
+ const filteredFileIDs = files.filter((file) => !file.error).map(file => file.id)
|
|
|
|
|
|
const state = this.getPluginState()
|
|
|
|
|
|
// If we're still restoring state, wait for that to be done.
|
|
|
if (this.restored) {
|
|
|
return this.restored.then(() => {
|
|
|
- return this._afterUpload(fileIDs, uploadID)
|
|
|
+ return this.#afterUpload(filteredFileIDs, uploadID)
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -677,7 +667,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
|
|
|
// If we don't have to wait for encoding metadata or results, we can close
|
|
|
// the socket immediately and finish the upload.
|
|
|
- if (!this._shouldWaitAfterUpload()) {
|
|
|
+ if (!this.#shouldWaitAfterUpload()) {
|
|
|
closeSocketConnections()
|
|
|
const assemblies = assemblyIDs.map((id) => this.getAssembly(id))
|
|
|
this.uppy.addResultData(uploadID, { transloadit: assemblies })
|
|
@@ -707,8 +697,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
|
|
|
// Remove the Assembly ID list for this upload,
|
|
|
// it's no longer going to be used anywhere.
|
|
|
- const state = this.getPluginState()
|
|
|
- const uploadsAssemblies = { ...state.uploadsAssemblies }
|
|
|
+ const uploadsAssemblies = { ...this.getPluginState().uploadsAssemblies }
|
|
|
delete uploadsAssemblies[uploadID]
|
|
|
this.setPluginState({ uploadsAssemblies })
|
|
|
|
|
@@ -718,7 +707,7 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- _onError (err = null, uploadID) {
|
|
|
+ #onError = (err = null, uploadID) => {
|
|
|
const state = this.getPluginState()
|
|
|
const assemblyIDs = state.uploadsAssemblies[uploadID]
|
|
|
|
|
@@ -727,34 +716,35 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
this.activeAssemblies[assemblyID].close()
|
|
|
}
|
|
|
})
|
|
|
+ this.client.submitError(err)
|
|
|
}
|
|
|
|
|
|
- _onTusError (err) {
|
|
|
+ #onTusError =(err) => {
|
|
|
if (err && /^tus: /.test(err.message)) {
|
|
|
const xhr = err.originalRequest ? err.originalRequest.getUnderlyingObject() : null
|
|
|
const url = xhr && xhr.responseURL ? xhr.responseURL : null
|
|
|
- this.client.submitError(err, { url, type: 'TUS_ERROR' }).then((_) => {
|
|
|
+ this.client.submitError(err, { url, type: 'TUS_ERROR' }).then(() => {
|
|
|
// if we can't report the error that sucks
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
install () {
|
|
|
- this.uppy.addPreProcessor(this._prepareUpload)
|
|
|
- this.uppy.addPostProcessor(this._afterUpload)
|
|
|
+ this.uppy.addPreProcessor(this.#prepareUpload)
|
|
|
+ this.uppy.addPostProcessor(this.#afterUpload)
|
|
|
|
|
|
// We may need to close socket.io connections on error.
|
|
|
- this.uppy.on('error', this._onError)
|
|
|
+ this.uppy.on('error', this.#onError)
|
|
|
|
|
|
// Handle cancellation.
|
|
|
- this.uppy.on('cancel-all', this._onCancelAll)
|
|
|
+ this.uppy.on('cancel-all', this.#onCancelAll)
|
|
|
|
|
|
// For error reporting.
|
|
|
- this.uppy.on('upload-error', this._onTusError)
|
|
|
+ this.uppy.on('upload-error', this.#onTusError)
|
|
|
|
|
|
if (this.opts.importFromUploadURLs) {
|
|
|
// No uploader needed when importing; instead we take the upload URL from an existing uploader.
|
|
|
- this.uppy.on('upload-success', this._onFileUploadURLAvailable)
|
|
|
+ this.uppy.on('upload-success', this.#onFileUploadURLAvailable)
|
|
|
} else {
|
|
|
this.uppy.use(Tus, {
|
|
|
// Disable tus-js-client fingerprinting, otherwise uploading the same file at different times
|
|
@@ -778,8 +768,8 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- this.uppy.on('restore:get-data', this._getPersistentData)
|
|
|
- this.uppy.on('restored', this._onRestored)
|
|
|
+ this.uppy.on('restore:get-data', this.#getPersistentData)
|
|
|
+ this.uppy.on('restored', this.#onRestored)
|
|
|
|
|
|
this.setPluginState({
|
|
|
// Contains Assembly status objects, indexed by their ID.
|
|
@@ -803,12 +793,12 @@ module.exports = class Transloadit extends BasePlugin {
|
|
|
}
|
|
|
|
|
|
uninstall () {
|
|
|
- this.uppy.removePreProcessor(this._prepareUpload)
|
|
|
- this.uppy.removePostProcessor(this._afterUpload)
|
|
|
- this.uppy.off('error', this._onError)
|
|
|
+ this.uppy.removePreProcessor(this.#prepareUpload)
|
|
|
+ this.uppy.removePostProcessor(this.#afterUpload)
|
|
|
+ this.uppy.off('error', this.#onError)
|
|
|
|
|
|
if (this.opts.importFromUploadURLs) {
|
|
|
- this.uppy.off('upload-success', this._onFileUploadURLAvailable)
|
|
|
+ this.uppy.off('upload-success', this.#onFileUploadURLAvailable)
|
|
|
}
|
|
|
|
|
|
const { capabilities } = this.uppy.getState()
|