@Tag(value="vaadin-upload") @NpmPackage(value="@vaadin/vaadin-upload", version="4.4.4") @JsModule(value="@vaadin/vaadin-upload/src/vaadin-upload.js") public abstract class GeneratedVaadinUpload<R extends GeneratedVaadinUpload<R>> extends Component implements HasStyle
Description copied from corresponding location in WebComponent:
<vaadin-upload>
is a Web Component for uploading multiple files with
drag and drop support.
Example:
<vaadin-upload></vaadin-upload>
The following shadow DOM parts are available for styling:
Part name | Description |
---|---|
primary-buttons |
Upload container |
upload-button |
Upload button |
drop-label |
Label for drop indicator |
drop-label-icon |
Icon for drop indicator |
file-list |
File list container |
The following state attributes are available for styling:
Attribute | Description | Part name |
---|---|---|
nodrop |
Set when drag and drop is disabled (e. g., on touch devices) | :host |
dragover |
A file is being dragged over the element | :host |
dragover-valid |
A dragged file is valid with maxFiles and accept criteria
|
:host |
Constructor and Description |
---|
GeneratedVaadinUpload() |
Modifier and Type | Method and Description |
---|---|
protected Registration |
addFileRejectListener(ComponentEventListener<GeneratedVaadinUpload.FileRejectEvent<R>> listener)
Adds a listener for
file-reject events fired by the webcomponent. |
protected Registration |
addFilesChangeListener(ComponentEventListener<GeneratedVaadinUpload.FilesChangeEvent<R>> listener)
Adds a listener for
files-changed events fired by the
webcomponent. |
protected Registration |
addMaxFilesReachedChangeListener(ComponentEventListener<GeneratedVaadinUpload.MaxFilesReachedChangeEvent<R>> listener)
Adds a listener for
max-files-reached-changed events fired by the
webcomponent. |
protected void |
addToAddButton(Component... components)
Adds the given components as children of this component at the slot
'add-button'.
|
protected void |
addToDropLabel(Component... components)
Adds the given components as children of this component at the slot
'drop-label'.
|
protected void |
addToDropLabelIcon(Component... components)
Adds the given components as children of this component at the slot
'drop-label-icon'.
|
protected void |
addToFileList(Component... components)
Adds the given components as children of this component at the slot
'file-list'.
|
protected Registration |
addUploadAbortListener(ComponentEventListener<GeneratedVaadinUpload.UploadAbortEvent<R>> listener)
Adds a listener for
upload-abort events fired by the
webcomponent. |
protected Registration |
addUploadBeforeListener(ComponentEventListener<GeneratedVaadinUpload.UploadBeforeEvent<R>> listener)
Adds a listener for
upload-before events fired by the
webcomponent. |
protected Registration |
addUploadErrorListener(ComponentEventListener<GeneratedVaadinUpload.UploadErrorEvent<R>> listener)
Adds a listener for
upload-error events fired by the
webcomponent. |
protected Registration |
addUploadProgressListener(ComponentEventListener<GeneratedVaadinUpload.UploadProgressEvent<R>> listener)
Adds a listener for
upload-progress events fired by the
webcomponent. |
protected Registration |
addUploadRequestListener(ComponentEventListener<GeneratedVaadinUpload.UploadRequestEvent<R>> listener)
Adds a listener for
upload-request events fired by the
webcomponent. |
protected Registration |
addUploadResponseListener(ComponentEventListener<GeneratedVaadinUpload.UploadResponseEvent<R>> listener)
Adds a listener for
upload-response events fired by the
webcomponent. |
protected Registration |
addUploadRetryListener(ComponentEventListener<GeneratedVaadinUpload.UploadRetryEvent<R>> listener)
Adds a listener for
upload-retry events fired by the
webcomponent. |
protected Registration |
addUploadStartListener(ComponentEventListener<GeneratedVaadinUpload.UploadStartEvent<R>> listener)
Adds a listener for
upload-start events fired by the
webcomponent. |
protected Registration |
addUploadSuccessListener(ComponentEventListener<GeneratedVaadinUpload.UploadSuccessEvent<R>> listener)
Adds a listener for
upload-success events fired by the
webcomponent. |
protected String |
getAcceptString()
Description copied from corresponding location in WebComponent:
|
protected String |
getCaptureString()
Description copied from corresponding location in WebComponent:
|
protected elemental.json.JsonArray |
getFilesJsonArray()
Description copied from corresponding location in WebComponent:
|
protected String |
getFormDataNameString()
Description copied from corresponding location in WebComponent:
|
protected elemental.json.JsonObject |
getHeadersJsonObject()
Description copied from corresponding location in WebComponent:
|
protected elemental.json.JsonObject |
getI18nJsonObject()
Description copied from corresponding location in WebComponent:
|
protected double |
getMaxFilesDouble()
Description copied from corresponding location in WebComponent:
|
protected double |
getMaxFileSizeDouble()
Description copied from corresponding location in WebComponent:
|
protected String |
getMethodString()
Description copied from corresponding location in WebComponent:
|
protected String |
getTargetString()
Description copied from corresponding location in WebComponent:
|
protected double |
getTimeoutDouble()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isMaxFilesReachedBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isNoAutoBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isNodropBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isWithCredentialsBoolean()
Description copied from corresponding location in WebComponent:
|
protected void |
remove(Component... components)
Removes the given child components from this component.
|
protected void |
removeAll()
Removes all contents from this component, this includes child components,
text content as well as child elements that have been added directly to
this component using the
Element API. |
protected void |
setAccept(String accept)
Description copied from corresponding location in WebComponent:
|
protected void |
setCapture(String capture)
Description copied from corresponding location in WebComponent:
|
protected void |
setFiles(elemental.json.JsonArray files)
Description copied from corresponding location in WebComponent:
|
protected void |
setFormDataName(String formDataName)
Description copied from corresponding location in WebComponent:
|
protected void |
setHeaders(elemental.json.JsonObject headers)
Description copied from corresponding location in WebComponent:
|
protected void |
setI18n(elemental.json.JsonObject i18n)
Description copied from corresponding location in WebComponent:
|
protected void |
setMaxFiles(double maxFiles)
Description copied from corresponding location in WebComponent:
|
protected void |
setMaxFileSize(double maxFileSize)
Description copied from corresponding location in WebComponent:
|
protected void |
setMethod(String method)
Description copied from corresponding location in WebComponent:
|
protected void |
setNoAuto(boolean noAuto)
Description copied from corresponding location in WebComponent:
|
protected void |
setNodrop(boolean nodrop)
Description copied from corresponding location in WebComponent:
|
protected void |
setTarget(String target)
Description copied from corresponding location in WebComponent:
|
protected void |
setTimeout(double timeout)
Description copied from corresponding location in WebComponent:
|
protected void |
setWithCredentials(boolean withCredentials)
Description copied from corresponding location in WebComponent:
|
protected void |
uploadFiles(elemental.json.JsonObject files)
Description copied from corresponding location in WebComponent:
|
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
getElement
addAttachListener
addDetachListener
protected boolean isNodropBoolean()
Description copied from corresponding location in WebComponent:
Define whether the element supports dropping files on it for uploading. By default it's enabled in desktop and disabled in touch devices because mobile devices do not support drag events in general. Setting it false means that drop is enabled even in touch-devices, and true disables drop in all devices.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
nodrop
property from the webcomponentprotected void setNodrop(boolean nodrop)
Description copied from corresponding location in WebComponent:
Define whether the element supports dropping files on it for uploading. By default it's enabled in desktop and disabled in touch devices because mobile devices do not support drag events in general. Setting it false means that drop is enabled even in touch-devices, and true disables drop in all devices.
nodrop
- the boolean value to setprotected String getTargetString()
Description copied from corresponding location in WebComponent:
The server URL. The default value is an empty string, which means that window.location will be used.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
target
property from the webcomponentprotected void setTarget(String target)
Description copied from corresponding location in WebComponent:
The server URL. The default value is an empty string, which means that window.location will be used.
target
- the String value to setprotected String getMethodString()
Description copied from corresponding location in WebComponent:
HTTP Method used to send the files. Only POST and PUT are allowed.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
method
property from the webcomponentprotected void setMethod(String method)
Description copied from corresponding location in WebComponent:
HTTP Method used to send the files. Only POST and PUT are allowed.
method
- the String value to setprotected elemental.json.JsonObject getHeadersJsonObject()
Description copied from corresponding location in WebComponent:
Key-Value map to send to the server. If you set this property as an
attribute, use a valid JSON string, for example: <vaadin-upload
headers=' "X-Foo": "Bar"
'>}
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
headers
property from the webcomponentprotected void setHeaders(elemental.json.JsonObject headers)
Description copied from corresponding location in WebComponent:
Key-Value map to send to the server. If you set this property as an
attribute, use a valid JSON string, for example: <vaadin-upload
headers=' "X-Foo": "Bar"
'>}
headers
- the JsonObject value to setprotected double getTimeoutDouble()
Description copied from corresponding location in WebComponent:
Max time in milliseconds for the entire upload process, if exceeded the request will be aborted. Zero means that there is no timeout.
<p>This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
timeout
property from the webcomponentprotected void setTimeout(double timeout)
Description copied from corresponding location in WebComponent:
Max time in milliseconds for the entire upload process, if exceeded the request will be aborted. Zero means that there is no timeout.
timeout
- the double value to set@Synchronize(property="files", value="files-changed") protected elemental.json.JsonArray getFilesJsonArray()
Description copied from corresponding location in WebComponent:
The array of files being processed, or already uploaded.
Each element is a File
object with a number of extra properties to track the upload process:
uploadTarget
: The target URL used to upload this file.elapsed
: Elapsed time since the upload started.elapsedStr
: Human-readable elapsed time.remaining
: Number of seconds remaining for the upload to
finish.remainingStr
: Human-readable remaining time for the upload to
finish.progress
: Percentage of the file already uploaded.speed
: Upload speed in kB/s.size
: File size in bytes.totalStr
: Human-readable total size of the file.loaded
: Bytes transferred so far.loadedStr
: Human-readable uploaded size at the moment.status
: Status of the upload process.error
: Error message in case the upload failed.abort
: True if the file was canceled by the user.complete
: True when the file was transferred to the
server.uploading
: True while transferring data to the server.
This property is synchronized automatically from client side when a 'files-changed' event happens.
files
property from the webcomponentprotected void setFiles(elemental.json.JsonArray files)
Description copied from corresponding location in WebComponent:
The array of files being processed, or already uploaded.
Each element is a File
object with a number of extra properties to track the upload process:
uploadTarget
: The target URL used to upload this file.elapsed
: Elapsed time since the upload started.elapsedStr
: Human-readable elapsed time.remaining
: Number of seconds remaining for the upload to
finish.remainingStr
: Human-readable remaining time for the upload to
finish.progress
: Percentage of the file already uploaded.speed
: Upload speed in kB/s.size
: File size in bytes.totalStr
: Human-readable total size of the file.loaded
: Bytes transferred so far.loadedStr
: Human-readable uploaded size at the moment.status
: Status of the upload process.error
: Error message in case the upload failed.abort
: True if the file was canceled by the user.complete
: True when the file was transferred to the
server.uploading
: True while transferring data to the server.files
- the JsonArray value to setprotected double getMaxFilesDouble()
Description copied from corresponding location in WebComponent:
Limit of files to upload, by default it is unlimited. If the value is set to one, native file browser will prevent selecting multiple files.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
maxFiles
property from the webcomponentprotected void setMaxFiles(double maxFiles)
Description copied from corresponding location in WebComponent:
Limit of files to upload, by default it is unlimited. If the value is set to one, native file browser will prevent selecting multiple files.
maxFiles
- the double value to set@Synchronize(property="maxFilesReached", value="max-files-reached-changed") protected boolean isMaxFilesReachedBoolean()
Description copied from corresponding location in WebComponent:
Specifies if the maximum number of files have been uploaded
This property is synchronized automatically from client side when a 'max-files-reached-changed' event happens.
maxFilesReached
property from the webcomponentprotected String getAcceptString()
Description copied from corresponding location in WebComponent:
Specifies the types of files that the server accepts. Syntax: a comma-separated list of MIME type patterns (wildcards are allowed) or file extensions. Notice that MIME types are widely supported, while file extensions are only implemented in certain browsers, so avoid using it. Example: accept="video/*,image/tiff" or accept=".pdf,audio/mp3"
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
accept
property from the webcomponentprotected void setAccept(String accept)
Description copied from corresponding location in WebComponent:
Specifies the types of files that the server accepts. Syntax: a comma-separated list of MIME type patterns (wildcards are allowed) or file extensions. Notice that MIME types are widely supported, while file extensions are only implemented in certain browsers, so avoid using it. Example: accept="video/*,image/tiff" or accept=".pdf,audio/mp3"
accept
- the String value to setprotected double getMaxFileSizeDouble()
Description copied from corresponding location in WebComponent:
Specifies the maximum file size in bytes allowed to upload. Notice that it is a client-side constraint, which will be checked before sending the request. Obviously you need to do the same validation in the server-side and be sure that they are aligned.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
maxFileSize
property from the webcomponentprotected void setMaxFileSize(double maxFileSize)
Description copied from corresponding location in WebComponent:
Specifies the maximum file size in bytes allowed to upload. Notice that it is a client-side constraint, which will be checked before sending the request. Obviously you need to do the same validation in the server-side and be sure that they are aligned.
maxFileSize
- the double value to setprotected String getFormDataNameString()
Description copied from corresponding location in WebComponent:
Specifies the 'name' property at Content-Disposition
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
formDataName
property from the webcomponentprotected void setFormDataName(String formDataName)
Description copied from corresponding location in WebComponent:
Specifies the 'name' property at Content-Disposition
formDataName
- the String value to setprotected boolean isNoAutoBoolean()
Description copied from corresponding location in WebComponent:
Prevents upload(s) from immediately uploading upon adding file(s). When
set, you must manually trigger uploads using the uploadFiles
method
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
noAuto
property from the webcomponentprotected void setNoAuto(boolean noAuto)
Description copied from corresponding location in WebComponent:
Prevents upload(s) from immediately uploading upon adding file(s). When
set, you must manually trigger uploads using the uploadFiles
method
noAuto
- the boolean value to setprotected boolean isWithCredentialsBoolean()
Description copied from corresponding location in WebComponent:
Set the withCredentials flag on the request.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
withCredentials
property from the webcomponentprotected void setWithCredentials(boolean withCredentials)
Description copied from corresponding location in WebComponent:
Set the withCredentials flag on the request.
withCredentials
- the boolean value to setprotected String getCaptureString()
Description copied from corresponding location in WebComponent:
Pass-through to input's capture attribute. Allows user to trigger device inputs such as camera or microphone immediately.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
capture
property from the webcomponentprotected void setCapture(String capture)
Description copied from corresponding location in WebComponent:
Pass-through to input's capture attribute. Allows user to trigger device inputs such as camera or microphone immediately.
capture
- the String value to setprotected elemental.json.JsonObject getI18nJsonObject()
Description copied from corresponding location in WebComponent:
The object used to localize this component. For changing the default localization, change the entire i18n object or just the property you want to modify.
The object has the following JSON structure and default values:
{
dropFiles: {
one: 'Drop file here
many: 'Drop files here
},
addFiles: {
one: 'Select File...',
many: 'Upload Files...'
},
cancel: 'Cancel',
error: {
tooManyFiles: 'Too Many Files.',
fileIsTooBig: 'File is Too Big.',
incorrectFileType: 'Incorrect File Type.'
},
uploading: {
status: {
connecting: 'Connecting...',
stalled: 'Stalled.',
processing: 'Processing File...',
held: 'Queued'
},
remainingTime: {
prefix: 'remaining time: ',
unknown: 'unknown remaining time'
},
error: {
serverUnavailable: 'Server Unavailable',
unexpectedServerError: 'Unexpected Server Error',
forbidden: 'Forbidden'
}
},
units: {
size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
},
formatSize: function(bytes) {
// returns the size followed by the best suitable unit
},
formatTime: function(seconds, [secs, mins, hours]) {
// returns a 'HH:MM:SS' string
}
}<p>This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
i18n
property from the webcomponentprotected void setI18n(elemental.json.JsonObject i18n)
Description copied from corresponding location in WebComponent:
The object used to localize this component. For changing the default localization, change the entire i18n object or just the property you want to modify.
The object has the following JSON structure and default values:
{
dropFiles: {
one: 'Drop file here
many: 'Drop files here
},
addFiles: {
one: 'Select File...',
many: 'Upload Files...'
},
cancel: 'Cancel',
error: {
tooManyFiles: 'Too Many Files.',
fileIsTooBig: 'File is Too Big.',
incorrectFileType: 'Incorrect File Type.'
},
uploading: {
status: {
connecting: 'Connecting...',
stalled: 'Stalled.',
processing: 'Processing File...',
held: 'Queued'
},
remainingTime: {
prefix: 'remaining time: ',
unknown: 'unknown remaining time'
},
error: {
serverUnavailable: 'Server Unavailable',
unexpectedServerError: 'Unexpected Server Error',
forbidden: 'Forbidden'
}
},
units: {
size: ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
},
formatSize: function(bytes) {
// returns the size followed by the best suitable unit
},
formatTime: function(seconds, [secs, mins, hours]) {
// returns a 'HH:MM:SS' string
}
}
i18n
- the JsonObject value to setprotected void uploadFiles(elemental.json.JsonObject files)
Description copied from corresponding location in WebComponent:
Triggers the upload of any files that are not completed
files
- Missing documentation!protected Registration addFileRejectListener(ComponentEventListener<GeneratedVaadinUpload.FileRejectEvent<R>> listener)
file-reject
events fired by the webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addUploadAbortListener(ComponentEventListener<GeneratedVaadinUpload.UploadAbortEvent<R>> listener)
upload-abort
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addUploadBeforeListener(ComponentEventListener<GeneratedVaadinUpload.UploadBeforeEvent<R>> listener)
upload-before
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addUploadErrorListener(ComponentEventListener<GeneratedVaadinUpload.UploadErrorEvent<R>> listener)
upload-error
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addUploadProgressListener(ComponentEventListener<GeneratedVaadinUpload.UploadProgressEvent<R>> listener)
upload-progress
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addUploadRequestListener(ComponentEventListener<GeneratedVaadinUpload.UploadRequestEvent<R>> listener)
upload-request
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addUploadResponseListener(ComponentEventListener<GeneratedVaadinUpload.UploadResponseEvent<R>> listener)
upload-response
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addUploadRetryListener(ComponentEventListener<GeneratedVaadinUpload.UploadRetryEvent<R>> listener)
upload-retry
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addUploadStartListener(ComponentEventListener<GeneratedVaadinUpload.UploadStartEvent<R>> listener)
upload-start
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addUploadSuccessListener(ComponentEventListener<GeneratedVaadinUpload.UploadSuccessEvent<R>> listener)
upload-success
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addFilesChangeListener(ComponentEventListener<GeneratedVaadinUpload.FilesChangeEvent<R>> listener)
files-changed
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addMaxFilesReachedChangeListener(ComponentEventListener<GeneratedVaadinUpload.MaxFilesReachedChangeEvent<R>> listener)
max-files-reached-changed
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected void addToAddButton(Component... components)
components
- The components to add.protected void addToDropLabelIcon(Component... components)
components
- The components to add.protected void addToDropLabel(Component... components)
components
- The components to add.protected void addToFileList(Component... components)
components
- The components to add.protected void remove(Component... components)
components
- The components to remove.IllegalArgumentException
- if any of the components is not a child of this component.protected void removeAll()
Element
API.Copyright © 2025. All rights reserved.