mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-23 10:18:40 +00:00
3.1 KiB
3.1 KiB
| type | order | title | permalink |
|---|---|---|---|
| api | 0 | Architecture | api/ |
Work in progress, API not stable. Last update: 2015-12-03
The Gist
import Uppy from './src/core';
import { DragDrop, Tus10 } from './src/plugins';
const uppy = new Uppy({wait: false});
const files = uppy
.use(DragDrop, {selector: '#upload-target'})
.use(Tus10, {endpoint: 'http://master.tus.io:8080'})
.run();
Core
- Core class
Uppyaccepts objectoptions(with general options), and exposes methods.usefor adding plugins and.setfor setting options. - We create a new instance of
Uppyand call.useon it, passing the plugins and their options. - Then
runis called to get things going. - Plugins have types:
presetter,orchestrator,progressindicator,acquirer,uploader, andpresenter(more could be added in the future). Whenuseis called, each plugin’srunmethod is added to an array of corresponding types,methods. - Ok, now the tricky part. Core’s method
runiterates over plugin types in a waterfall manner — eachrunTypesruns itsmethods in parallel and returns an array of results (files) to the next plugin type in the waterfall. This way we first get all the of files fromDragDrop,Dropbox,Instagramand other inputs — then parse them somehow — and then upload:
Plugins
- Plugins are registered like this:
uppy
.use(DragDrop, {selector: '#upload-target'})
.use(Tus10, {endpoint: 'http://master.tus.io:8080'})
Internally, plugins extend from a Plugin class, see that for details.
- Settings and handlers are chainable, set like this:
uppy
.set({ wait: true })
.use(Modal, {target: 'div#mycontainer', some: 'config'})
.use(DragDrop, {target: Modal})
.use(Instagram, {target: Modal, some: 'config'})
.on('progress', handleProgress)
.on('error', handleError);
-
In
Uppyeverything is a plugin: aModaldialog,Drag & Drop,Instagram. We borrow general approach from the new Babel and PostCSS — each chunk of functionality exists as separate plugin — easier to pick and choose exactly what you need to get a lightweight solution for production, while also easier to develop and avoid merge conflicts. -
There will be a simplified preset that strings together many Plugins using sane defaults.
uppy
.use(Basic, {target: 'div#mycontainer', endpoint: 'http://master.tus.io:8080'})
.run();
-
Users will be able to rol out themes and style settings via plain CSS .
-
Would be cool if you could use whatever drag & drop library you wanted (DropZone) with our wrapper.
