|
@@ -162,6 +162,17 @@ module.exports = class Transloadit extends Plugin {
|
|
this.core.bus.emit('transloadit:result', stepName, result, this.getAssembly(assemblyId))
|
|
this.core.bus.emit('transloadit:result', stepName, result, this.getAssembly(assemblyId))
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ onAssemblyFinished (url) {
|
|
|
|
+ this.client.getAssemblyStatus(url).then((assembly) => {
|
|
|
|
+ this.updateState({
|
|
|
|
+ assemblies: Object.assign({}, this.state.assemblies, {
|
|
|
|
+ [assembly.assembly_id]: assembly
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ this.core.emit('transloadit:complete', assembly)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
connectSocket (assembly) {
|
|
connectSocket (assembly) {
|
|
const socket = new StatusSocket(
|
|
const socket = new StatusSocket(
|
|
assembly.websocket_url,
|
|
assembly.websocket_url,
|
|
@@ -180,10 +191,11 @@ module.exports = class Transloadit extends Plugin {
|
|
|
|
|
|
if (this.opts.waitForEncoding) {
|
|
if (this.opts.waitForEncoding) {
|
|
socket.on('finished', () => {
|
|
socket.on('finished', () => {
|
|
- this.core.emit('transloadit:complete', assembly)
|
|
|
|
|
|
+ this.onAssemblyFinished(assembly.assembly_ssl_url)
|
|
})
|
|
})
|
|
} else if (this.opts.waitForMetadata) {
|
|
} else if (this.opts.waitForMetadata) {
|
|
socket.on('metadata', () => {
|
|
socket.on('metadata', () => {
|
|
|
|
+ this.onAssemblyFinished(assembly.assembly_ssl_url)
|
|
this.core.emit('transloadit:complete', assembly)
|
|
this.core.emit('transloadit:complete', assembly)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -249,21 +261,15 @@ module.exports = class Transloadit extends Plugin {
|
|
// Remove this handler once we find the assembly we needed.
|
|
// Remove this handler once we find the assembly we needed.
|
|
this.core.emitter.off('transloadit:complete', onAssemblyFinished)
|
|
this.core.emitter.off('transloadit:complete', onAssemblyFinished)
|
|
|
|
|
|
- this.client.getAssemblyStatus(assembly.assembly_ssl_url).then((assembly) => {
|
|
|
|
- this.updateState({
|
|
|
|
- assemblies: Object.assign({}, this.state.assemblies, {
|
|
|
|
- [assembly.assembly_id]: assembly
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- // TODO set the `file.uploadURL` to a result?
|
|
|
|
- // We will probably need an option here so the plugin user can tell us
|
|
|
|
- // which result to pick…?
|
|
|
|
-
|
|
|
|
- fileIDs.forEach((fileID) => {
|
|
|
|
- this.core.emit('core:postprocess-complete', fileID)
|
|
|
|
- })
|
|
|
|
- }).then(resolve, reject)
|
|
|
|
|
|
+ // TODO set the `file.uploadURL` to a result?
|
|
|
|
+ // We will probably need an option here so the plugin user can tell us
|
|
|
|
+ // which result to pick…?
|
|
|
|
+
|
|
|
|
+ fileIDs.forEach((fileID) => {
|
|
|
|
+ this.core.emit('core:postprocess-complete', fileID)
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ resolve()
|
|
}
|
|
}
|
|
|
|
|
|
const onAssemblyError = (assembly, error) => {
|
|
const onAssemblyError = (assembly, error) => {
|