Commit graph

67 commits

Author SHA1 Message Date
Renée Kooi
2e52d27717
transloadit: Use this.core.log 2017-12-18 10:44:34 +01:00
Renée Kooi
4e3a642756
transloadit: Emit transloadit:complete correctly after restore with waitForMetadata. 2017-12-18 10:44:34 +01:00
Renée Kooi
d7e3e0d9ee
transloadit: Emit file upload error if assembly fails. 2017-12-18 10:44:33 +01:00
Renée Kooi
4aa450db7c
transloadit: Fix transloadit:complete being emitted twice when waitForMetadata: true 2017-12-18 10:44:33 +01:00
Renée Kooi
d5a6b0fe3c
transloadit: Emit missed events on restore.
Diffs assembly status to find new `uploads` and `results`, and emits
`transloadit:upload` and `transloadit:result` events accordingly.
Also emits `transloadit:complete` for newly finished assemblies
and `transloadit:assembly-error` for assemblies that failed.

This feature needs to store some custom data with the RestoreFiles
plugin. It does this by adding a `restore:get-data` event that gets a
callback as a parameter. This callback stores custom plugin data. It's
not great but idk.

    core.on('restore:get-data', (setData) => {
      setData({ whatever: 'beepboop' })
    })
2017-12-18 10:44:33 +01:00
Renée Kooi
452a9a5a0e
transloadit: load assembly statuses on restore 2017-12-18 10:44:33 +01:00
Artur Paikin
ed9aa1a537 🚨this.core to this.uppy everywhere
danger again
2017-12-08 17:34:33 -05:00
Artur Paikin
6f510f4679
Merge branch 'master' into chore/refactors 2017-12-07 17:03:55 -05:00
Artur Paikin
526b506e31 🚨🚨🚨 Remove core: prefix from all events 🚨🚨🚨
Danger! Danger!

`core:upload-progress` becomes `upload-progress` and so on.

Oh my, here goes.
2017-12-07 16:57:24 -05:00
Renée Kooi
822dcd0903
transloadit: Remove TODO comment 2017-12-04 12:36:26 +01:00
Artur Paikin
1bd1e410d9 move plugins/Plugin.js to core/Plugin.js
to better separate concerns and later split into packages
2017-11-27 22:03:38 -05:00
Renée Kooi
4682f59fc6
xhrupload,tus,transloadit: Ignore errored files. 2017-11-10 16:55:57 +01:00
Renée Kooi
a916983068
transloadit: Do not reject the entire upload() when a single assembly fails 2017-11-10 16:55:57 +01:00
Renée Kooi
0be93a5e7a
transloadit: Configure resume: false for the Tus plugin. 2017-11-03 13:47:57 +01:00
Renée Kooi
8d9a1fa03d Merge pull request #390 from transloadit/full-retry
Restart the entire upload on retry, fixes #387.
2017-10-18 09:55:28 +02:00
Renée Kooi
e69d8f72a8
transloadit: Emit file upload error if assembly fails. 2017-10-17 12:21:50 +02:00
Renée Kooi
ada6b14dc1
Reuse upload URL by default for tus, reset it for each new :tl: assembly. 2017-10-17 12:08:52 +02:00
Renée Kooi
0ba8b84d37
transloadit: Use Translator for language strings 2017-10-09 14:57:57 +02:00
Renée Kooi
2ec1696455
plugins: add get/setPluginState methods 2017-09-26 17:10:47 +02:00
Artur Paikin
fbf53b4576 Merge pull request #321 from goto-bus-stop/chore/unmagic
transloadit: remove `this.state` getter
2017-09-09 19:16:33 -04:00
Renée Kooi
e5d83ed2f2
transloadit,webcam: Rename updateStatesetPluginState 2017-09-08 13:43:02 +02:00
Renée Kooi
c9eacb8a8d
transloadit: remove this.state getter 2017-09-07 20:26:41 +02:00
Renée Kooi
850c2bb526
Handle sync returns and throws in possibly-async function options
Fixes #315

This patch makes some function options that can return Promises a bit
easier to use. Previously, most of these required that the user returned
a Promise, even if they were doing sync work. Also, if an error was
thrown inside the provided function, it would actually throw the error
instead of rejecting a Promise, thus not allowing Uppy to show an error
notification or anything.

Instead, these options now use this pattern:

```js
Promise.resolve()
  .then(() => this.opts.onSomething(argument))
```

Inside a `.then()` handler, both a Promise and a plain value can be
returned, and the resulting Promise will be resolved with the correct
value. Also, any sync errors `throw`n inside a `.then()` handler cause
the returned Promise to be rejected.
2017-09-05 19:01:46 +02:00
Renée Kooi
11b820e68c
transloadit: Remove event listener correctly on uninstall 2017-09-01 12:31:07 +02:00
Renée Kooi
191a1de41f
transloadit: Fail the postprocessing step when /add_file fails. 2017-09-01 12:31:07 +02:00
Renée Kooi
727c4ee145
transloadit: Name some things. 2017-09-01 12:31:06 +02:00
Renée Kooi
0e479497e2
transloadit: Clarify how only :tl: metadata is sent to tus 2017-09-01 12:31:06 +02:00
Renée Kooi
13ac3350a4
transloadit: Emit core:upload-error if file cannot be added to assembly 2017-09-01 12:31:06 +02:00
Renée Kooi
d856023217
transloadit: Fix undefined opts 2017-09-01 12:31:06 +02:00
Renée Kooi
cebc0ee581
transloadit: First working URL import 2017-09-01 12:31:06 +02:00
Renée Kooi
cde56fa491
transloadit: Begin work on importing uploaded URLs into assembly.
Support uploading to elsewhere, then importing URLs into assembly.
2017-09-01 12:30:43 +02:00
Renée Kooi
617c5e525c
transloadit: Return assembly information from createAssembly.
We don't actually use this right now but this is what I would've
expected a method called `createAssembly` to do.
2017-09-01 12:27:24 +02:00
Artur Paikin
055b233e54 this.core.emit('informer') --> this.core.info() 2017-08-24 23:58:59 +03:00
Renée Kooi
639489fc91
transloadit: Fix afterUpload never resolving when no assemblies were necessary. 2017-08-24 14:34:20 +02:00
Renée Kooi
5750efab90
transloadit: Add test for alwaysRunAssembly 2017-08-24 13:49:34 +02:00
Renée Kooi
6968dbe19f
transloadit: Fix crash when no files are being uploaded 2017-08-24 13:44:52 +02:00
Artur Paikin
2bd4364968 Merge pull request #290 from goto-bus-stop/feature/tl-assembly-without-files
transloadit: Add `alwaysRunAssembly` option
2017-08-23 17:35:31 +03:00
Renée Kooi
7572a9b46b
transloadit: Add alwaysRunAssembly option
This adds back the ability to run assemblies without uploading any
files, which is useful in case the assembly uses an import robot.

To do this, this patch adds a new state key to the Transloadit plugin's
state, named `uploadsAssemblies` (open to bikeshedding lol)
This key associates assembly IDs with the upload ID that triggered them.
This allows figuring out which assemblies need to finish before
resolving the upload promise.

The upload ID is now passed into preprocessors and postprocessors so
they can use it to store metadata that is related to an upload instead
of a single file.

When `alwaysRunAssembly` is set to true, and zero files are available
for upload, an assembly is created anyway for the options returned by
`getAssemblyOptions(null)`.

It turns out that `afterUpload` actually didn't work correctly if
multiple assemblies were used for a single upload. I changed it so that
it does, and incidentally that also made it work again with zero-file
assemblies.
2017-08-22 15:34:34 +02:00
Renée Kooi
ffb36428f3
transloadit: Fix crash when no files are being uploaded 2017-08-22 14:15:06 +02:00
Renée Kooi
a58b2cf1a2
transloadit: fix some emit() calls 2017-08-22 12:21:07 +02:00
Renée Kooi
33f1388f6c
transloadit: Fix crash when waitFor options are false
Fix by @stevegeek
Closes #279
2017-08-15 17:18:18 +02:00
Renée Kooi
9ef22f5529
transloadit: Rename :assembly event to :assembly-created 2017-07-21 13:24:14 +02:00
Renée Kooi
b847f35568
core: Add getFile method. 2017-07-20 18:13:24 +02:00
Renée Kooi
a1c0200d89
transloadit: Also validate params from getAssemblyOptions. 2017-07-11 20:35:39 +02:00
Renée Kooi
5f7d3d79cf
transloadit: Add getAssemblyOptions.
This patch adds a `getAssemblyOptions` function option to the
Transloadit plugin. This option can return an object or a Promise for an
object to configure the Transloadit assembly. The returned object can
contain `params`, a `signature`, and `fields`.

`getAssemblyOptions` is called on each file, so each file can return a
different set of options. Files that returned the same options are
bundled together and run through a single assembly. Files that return
different options will be run through different assemblies.

This means that it is now possible to make assembly parameters depend on
user input from eg. the MetaData plugin, and have different parameters
for different files. It's now also possible to generate very short-lived
signatures on the server when an upload starts.
2017-07-11 20:35:39 +02:00
Renée Kooi
c524b10cbf
transloadit: Retrieve completed assembly for complete event
Previously, the initial assembly data was reused in the complete event…
🙈
This patch fetches the assembly status again when the socket emits
`assembly_finished`, so we're always up to date.
2017-07-10 21:33:51 +02:00
Renée Kooi
ee4a58420f
transloadit: Add assembly data to :upload, :result events.
This adds a new parameter to the transloadit:upload and
transloadit:result events, containing the assembly data.

```js
uppy.on('transloadit:upload', (file, assembly) => {
  console.log('an upload was completed with template id', assembly.template_id)
})
```

```js
uppy.on('transloadit:result', (stepName, result, assembly) => {
  console.log(`${stepName}:`, result, 'from', assembly)
})
```
2017-07-07 15:30:04 +02:00
Renée Kooi
a5878b17dc
transloadit: Emit event when an assembly is created.
The `transloadit:assembly` event is emitted when an assembly is created.
It receives the assembly data in the first parameter, and the file IDs
of the files that it belongs to in the second parameter.

```js
uppy.on('transloadit:assembly', (assembly, fileIDs) => {
  const files = fileIDs.map((id) => uppy.getState().files[id])
  console.log({ assembly, files })
})
```
2017-07-07 15:22:58 +02:00
Renée Kooi
7f6cb7a65d
transloadit: Mark postprocessing as complete if an error occurred
This way stray postprocessing state doesn't interfere in future uploads.
2017-06-08 13:36:33 +02:00
Renée Kooi
d0813241a5
transloadit: Fix assembly error handling
The `afterUpload` handler wasn't returning a Promise anymore after I
changed it to support multiple simultaneous assemblies. Now it works
again, and `core.upload()` will reject if the assembly failed.
2017-06-07 14:58:33 +02:00