type: api order: 0
Work in progress, API not stable. Last update: 2015-12-03
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();
Uppy
accepts object options
(with general options), and exposes methods .use
for adding plugins and .set
for setting options.Uppy
and call .use
on it, passing the plugins and their options.run
is called to get things going.presetter
, selecter
and uploader
(more could be added in the future). When use
is called, each plugin’s run
method is added to an array of corresponding types, methods
.run
iterates over plugin types in a waterfall manner — each runTypes
runs its method
s 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 from DragDrop
, Dropbox
, Instagram
and other inputs — then parse them somehow — and then upload:Plugins are registered like this:
uppy
.use(DragDrop, {selector: '#upload-target'})
.use(Tus10, {endpoint: 'http://master.tus.io:8080'})
Internally, plugins extend from a UppyPlugin
class, see that for details.
javascript
uppy
.set({ wait: true })
.use(transloaditModal, {some: 'config'})
.use(dragdrop, {target: transloaditModal})
.use(instagram, {some: 'config'})
.on('progress', handleProgress)
.on('error', handleError);
In Uppy
everything is a plugin: a Modal
dialog, 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 version that includes all the necessary plugins and sane defaults.
uppyDist
.set({ wait: true })
.run();
Users should be able to set themes and style settings in config: .use(myTheme)
.
Would be cool if you could use whatever drag & drop library you wanted (DropZone) with our wrapper.