Data Types

UploadWidgetConfig

The configuration object passed to the Upload Widget's open() method has this structure:

Structure

Example

{
"editor": {
"images": {
"crop": true,
"cropRatio": 1,
"cropShape": "circ"
}
},
"layout": "modal",
"maxFileCount": 1,
"maxFileSizeBytes": 10485760,
"metadata": {
"myCustomField1": true,
"myCustomField2": {
"hello": "world"
},
"anotherCustomField": 42
},
"mimeTypes": [
"image/jpeg"
],
"multi": false,
"onUpdate": Function,
"onValidate": Function,
"path": {
"fileName": "image.jpg",
"fileNameVariablesEnabled": true,
"folderPath": "/uploads",
"folderPathVariablesEnabled": true
},
"showFinishButton": true,
"showRemoveButton": true,
"styles": {
"colors": {
"active": "#528fff",
"primary": "#377dff"
},
"fontSizes": {
"base": 16
}
},
"tags": [
"images/profile"
]
}

Properties

container

The container element to render the widget in.

Supported values:

string: a DOM selector for an existing element on the page, e.g. "body" or "#container".

object: a DOM element.

Only add this property if layout is set to "inline".

Required: No

editor

Image editor options for the Upload Widget.

Type: UploadWidgetEditor

Required: No

layout

If "modal" is used, then the Upload Widget will render as a modal when open() is called.

If "inline" is used, then the Upload Widget will render as an inline dropzone when open() is called.

If "inline" is used, then you must set the container property to point to the element you want to render the dropzone widget inside.

Default: "modal"

Type: String

Allowed Values: "inline", "modal"

Example: "modal"

Required: No

locale

Text to appear in the Upload Widget's buttons and other UI elements. Defaults to the EN/US locale.

Type: UploadWidgetLocale

Required: No

maxFileCount

Maximum number of files allowed.

Default: infinity if multi=true

Type: Number

Example: 1

Required: No

maxFileSizeBytes

Maximum file size allowed.

Default: infinity

Type: Number

Example: 10485760

Required: No

metadata

An arbitrary JSON object to store against the uploaded file(s) as metadata.

You can retrieve this later via a GetFileDetails request.

Type: FileMetadata

Required: No

mimeTypes

File type filter.

Type: String[]

Example: ["image/jpeg"]

Required: No

multi

Enables/disables multiple file uploads.

Default: false

Type: Boolean

Example: false

Required: No

onUpdate

Callback taking a single parameter: an array of UploadWidgetResult.

Fired each time a file is uploaded or removed.

Type: Function

Required: No

onValidate

Callback taking a single parameter: a DOM File object.

Fired before each file upload.

If Promise<string> is returned, then the string is displayed to the user as a validation error message and the upload is cancelled.

If Promise<undefined> is returned, then the upload is allowed to continue.

Type: Function

Required: No

path

The path to upload the file(s) to.

Type: FilePathDefinition

Required: No

showFinishButton

Shows/hides the 'finish' button, which is displayed after files are uploaded.

If showFinishButton = false, multi = false, and layout = "modal", then the modal will close immediately after the file is uploaded (instead of showing the file to the user).

Default: true

Type: Boolean

Required: No

showRemoveButton

Shows/hides the 'remove' button, which is displayed next to each file after it's uploaded.

Default: true

Type: Boolean

Required: No

styles

Styling options for the Upload Widget.

Type: UploadWidgetStyles

Required: No

tags

The tags you specify here determine which rules will be executed for the upload(s).

You create rules in the Upload Dashboard, and choose which tags trigger each rule.

Rules include: max file size checks, traffic limit checks, rate limit checks, etc.

Type: String[]

Example: ["images/profile"]

Required: No

Was this section helpful? Yes No

You are using an outdated browser.

This website requires a modern web browser -- the latest versions of these browsers are supported: