Class GeneratedVaadinUpload<R extends GeneratedVaadinUpload<R>>

  • All Implemented Interfaces:
    AttachNotifier, DetachNotifier, HasElement, HasStyle, Serializable
    Direct Known Subclasses:
    Upload

    @Tag("vaadin-upload")
    @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="23.1.4") @NpmPackage(value="@vaadin/upload",version="23.1.4") @NpmPackage(value="@vaadin/vaadin-upload",version="23.1.4")
    @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@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>

    Styling

    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

    See ThemableMixin – how to apply styles for shadow parts

    See Also:
    Serialized Form
    • Constructor Detail

      • GeneratedVaadinUpload

        public GeneratedVaadinUpload()
    • Method Detail

      • isNodropBoolean

        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.

        Returns:
        the nodrop property from the webcomponent
      • setNodrop

        protected 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.

        Parameters:
        nodrop - the boolean value to set
      • getTargetString

        protected 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.

        Returns:
        the target property from the webcomponent
      • setTarget

        protected 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.

        Parameters:
        target - the String value to set
      • getMethodString

        protected 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.

        Returns:
        the method property from the webcomponent
      • setMethod

        protected void setMethod​(String method)

        Description copied from corresponding location in WebComponent:

        HTTP Method used to send the files. Only POST and PUT are allowed.

        Parameters:
        method - the String value to set
      • getHeadersJsonObject

        protected 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.

        Returns:
        the headers property from the webcomponent
      • setHeaders

        protected 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"'>}

        Parameters:
        headers - the JsonObject value to set
      • getTimeoutDouble

        protected 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.
                
         
        Returns:
        the timeout property from the webcomponent
      • setTimeout

        protected 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.

        Parameters:
        timeout - the double value to set
      • getFilesJsonArray

        @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.

        Returns:
        the files property from the webcomponent
      • setFiles

        protected 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.
        Parameters:
        files - the JsonArray value to set
      • getMaxFilesDouble

        protected 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.

        Returns:
        the maxFiles property from the webcomponent
      • setMaxFiles

        protected 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.

        Parameters:
        maxFiles - the double value to set
      • isMaxFilesReachedBoolean

        @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.

        Returns:
        the maxFilesReached property from the webcomponent
      • getAcceptString

        protected 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.

        Returns:
        the accept property from the webcomponent
      • setAccept

        protected 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"

        Parameters:
        accept - the String value to set
      • getMaxFileSizeDouble

        protected 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.

        Returns:
        the maxFileSize property from the webcomponent
      • setMaxFileSize

        protected 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.

        Parameters:
        maxFileSize - the double value to set
      • getFormDataNameString

        protected 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.

        Returns:
        the formDataName property from the webcomponent
      • setFormDataName

        protected void setFormDataName​(String formDataName)

        Description copied from corresponding location in WebComponent:

        Specifies the 'name' property at Content-Disposition

        Parameters:
        formDataName - the String value to set
      • isNoAutoBoolean

        protected 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.

        Returns:
        the noAuto property from the webcomponent
      • setNoAuto

        protected 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

        Parameters:
        noAuto - the boolean value to set
      • isWithCredentialsBoolean

        protected 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.

        Returns:
        the withCredentials property from the webcomponent
      • setWithCredentials

        protected void setWithCredentials​(boolean withCredentials)

        Description copied from corresponding location in WebComponent:

        Set the withCredentials flag on the request.

        Parameters:
        withCredentials - the boolean value to set
      • getCaptureString

        protected 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.

        Returns:
        the capture property from the webcomponent
      • setCapture

        protected 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.

        Parameters:
        capture - the String value to set
      • getI18nJsonObject

        protected 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.
                
         
        Returns:
        the i18n property from the webcomponent
      • setI18n

        protected 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
                          }
                        }
                
         
        Parameters:
        i18n - the JsonObject value to set
      • uploadFiles

        protected void uploadFiles​(elemental.json.JsonObject files)

        Description copied from corresponding location in WebComponent:

        Triggers the upload of any files that are not completed

        Parameters:
        files - Missing documentation!
      • addToDropLabelIcon

        protected void addToDropLabelIcon​(Component... components)
        Adds the given components as children of this component at the slot 'drop-label-icon'.
        Parameters:
        components - The components to add.
        See Also:
        MDN page about slots, Spec website about slots
      • remove

        protected void remove​(Component... components)
        Removes the given child components from this component.
        Parameters:
        components - The components to remove.
        Throws:
        IllegalArgumentException - if any of the components is not a child of this component.
      • removeAll

        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.