Core module that orchistrated everything in Uppy, exposing state, events and methods.


const uppy = Uppy({
id: 'uppy',
autoProceed: true,
restrictions: {
maxFileSize: false,
maxNumberOfFiles: false,
minNumberOfFiles: false,
allowedFileTypes: false
meta: {},
onBeforeFileAdded: (currentFile, files) => Promise.resolve(),
onBeforeUpload: (files, done) => Promise.resolve(),
locale: defaultLocale

id: 'uppy'

A site-wide unique ID for the instance.
If multiple Uppy instances are being used, for example on two different pages, an id should be specified.
This allows Uppy to store information in localStorage without colliding with other Uppy instances.

Note that this ID should be persistent across page reloads and navigation—it shouldn’t be a random number that’s different every time Uppy is loaded.
For example, if one Uppy instance is used to upload user avatars, and another to add photos to a blog post, you might use:

const avatarUploader = Uppy({ id: 'avatar' })
const photoUploader = Uppy({ id: 'post' })

autoProceed: true

Starts upload automatically after the first file is selected.

restrictions: {}

Optionally provide rules and conditions for which files can be selected.


  • maxFileSize number
  • maxNumberOfFiles number
  • minNumberOfFiles number
  • allowedFileTypes array of wildcards or exact mime types, like image/*

meta: {}

Metadata object, pass things like public keys, usernames, tags or whatever:

meta: {
username: 'John'

Can be altered with uppy.setMeta({username: 'Peter'}) method.

onBeforeFileAdded: (currentFile, files) => Promise.resolve()

A function run before a file is added to Uppy. Gets passed (currentFile, files) where currentFile is a file that is about to be added, and files is an object with all files that already are in Uppy. Return Promise.resolve to proceed with adding the file or Promise.reject to abort. Use this function to run any number of custom checks on the selected file, or manipulating it, like optimizing a file name, for example.

onBeforeFileAdded: (currentFile, files) => {
if (currentFile.name === 'pitercss-IMG_0616.jpg') {
return Promise.resolve()
return Promise.reject('this is not the file I was looking for')

onBeforeUpload: (files, done) => Promise.resolve()

A function run before an upload begins. Gets passed files object with all files that already are in Uppy. Return Promise.resolve to proceed with adding the file or Promise.reject to abort. Use this to check if all files or their total number match your requirements, or manipulate all the files at once before upload.

onBeforeUpload: (files) => {
if (Object.keys(files).length < 2) {
return Promise.reject('too few files')
return Promise.resolve()

locale: {}

Same deal as in plugins, this allows you to override language strings:

locale: {
strings: {
youCanOnlyUploadX: {
0: 'You can only upload %{smart_count} file',
1: 'You can only upload %{smart_count} files'
youHaveToAtLeastSelectX: {
0: 'You have to select at least %{smart_count} file',
1: 'You have to select at least %{smart_count} files'
exceedsSize: 'This file exceeds maximum allowed size of',
youCanOnlyUploadFileTypes: 'You can only upload:'

As well as the pluralization function, which is used to determin which string will be used for the provided smart_count number.

For example, for Icelandic language the pluralization function will be:

locale: {
pluralize: (n) => (n % 10 !== 1 || n % 100 === 11) ? 1 : 0

We are using a forked Polyglot.js.


uppy.use(plugin, opts)

Add a plugin to Uppy, with an optional plugin options object.

const Uppy = require('uppy/lib/core')
const DragDrop = require('uppy/lib/plugins/DragDrop')
const uppy = Uppy()
uppy.use(DragDrop, {target: 'body'})


Initializes everything after setup. Must be called before calling .upload() or using Uppy in any meaningful way.


Get the uppy instance ID, see the id option.


Add a new file to Uppy’s internal state.

name: 'my-file.jpg', // file name
type: 'image/jpeg', // file type
data: fileBlob, // file blob
source: 'Local', // optional, sets what added the file, for example, Instagram
isRemote: false // optional, set to true if actual file is not in the browser, but on some remote server, like when using uppy-server + Instagram, for example

addFile attemps to determine file type by magic bytes + the provided type + extension; then checks if the file can be added, considering uppy.opts.restrictions, sets metadata and generates a preview, if it’s an image.

If uppy.opts.autoProceed === true, Uppy will begin uploading after the first file is added.


A shortcut method that returns a specific file object from uppy.state by its fileID.

const file = uppy.getFile('uppyteamkongjpg1501851828779')
const img = document.createElement('img')
img.src = file.preivew


Update uppy.state. Usually this method is called internally, but in some cases it might be useful to alter something in uppy.state directly.

Uppy’s default state on initialization:

this.state = {
files: {},
capabilities: {
resumableUploads: false
totalProgress: 0,
meta: Object.assign({}, this.opts.meta)

Updating state:

smth: true

We don’t mutate uppy.state, so internally setState creates a new copy of state and replaces uppy.state with it. However, when updating values, it’s your responsibility to not mutate them, but instead create copies. See Redux docs for more info on this. Here’s an example from Uppy.Core that updates progress for a particular file in state:

const updatedFiles = Object.assign({}, uppy.getState().files)
const updatedFile = Object.assign({}, updatedFiles[fileID],
Object.assign({}, {
progress: Object.assign({}, updatedFiles[fileID].progress, {
bytesUploaded: data.bytesUploaded,
bytesTotal: data.bytesTotal,
percentage: Math.floor((data.bytesUploaded / data.bytesTotal * 100).toFixed(2))
updatedFiles[data.id] = updatedFile
uppy.setState({files: updatedFiles})


Returns uppy.state, which you can also use directly.


Alters global meta object is state, the one that can be set in Uppy options and gets merged with all newly added files.

uppy.setMeta({resize: 1500})

uppy.updateMeta(data, fileID)

Updated metadata for a specific file.

uppy.updateMeta('myfileID', {resize: 1500})


Stop all uploads in progress and clear file selection, set progress to 0. Basically, return things to the way they were before any user input.


Uninstall all plugins and close down this Uppy instance. Also runs uppy.reset() before uninstalling.


Logs stuff to console, only if uppy.opts.debug is set to true. Silent in production.


this.info('Oh my, something good happened!', 'success', 5000)


  • message string
  • type string info, warning, success or error
  • duration number in milliseconds


Start uploading selected files.

uppy.on('event', action)

Subscribe to an uppy-event. See full list of events below.


Uppy exposes events that you can subscribe to in your app:


Fired each time file upload progress is available, data object looks like this:

data = {
id: myimg12321323,
bytesUploaded: 2323254,
uppy.on('core:upload-progress', (data) => {
console.log(data.id, data.bytesUploaded, data.bytesTotal)


Fired when single upload is complete.

uppy.on('core:upload-success', (fileId, url) => {
var img = new Image()
img.width = 300
img.alt = fileId
img.src = url


Fired when all uploads are complete.

uppy.on('core:success', (fileCount) => {