Class HtmlFileInput

    • Method Detail

      • getData

        public final byte[] getData()
        Returns the in-memory data assigned to this file input element, if any.
        Returns:
        null if setData(byte[]) hasn't be used
      • setData

        public final void setData​(byte[] data)

        Assigns in-memory data to this file input element. During submission, instead of loading data from a file, the data is read from in-memory byte array.

        NOTE: Only use this method if you wish to upload in-memory data; if you instead wish to upload the contents of an actual file, use setValueAttribute(String), passing in the path to the file.

        Parameters:
        data - the in-memory data assigned to this file input element
      • getSubmitNameValuePairs

        public NameValuePair[] getSubmitNameValuePairs()

        Returns an array of NameValuePairs that are the values that will be sent back to the server whenever this element's containing form is submitted.

        THIS METHOD IS INTENDED FOR THE USE OF THE FRAMEWORK ONLY AND SHOULD NOT BE USED BY CONSUMERS OF HTMLUNIT. USE AT YOUR OWN RISK.

        Specified by:
        getSubmitNameValuePairs in interface SubmittableElement
        Overrides:
        getSubmitNameValuePairs in class HtmlInput
        Returns:
        the values that will be sent back to the server whenever this element's containing form is submitted
      • setContentType

        public void setContentType​(java.lang.String contentType)
        Sets the content type value that should be sent together with the uploaded file. If content type is not explicitly set, HtmlUnit will try to guess it from the file content.
        Parameters:
        contentType - the content type (null resets it)
      • getContentType

        public java.lang.String getContentType()
        Gets the content type that should be sent together with the uploaded file.
        Returns:
        the content type, or null if this has not been explicitly set and should be guessed from file content
      • getValue

        public java.lang.String getValue()
        Overrides:
        getValue in class HtmlInput
        Returns:
        the value
      • setValueAttribute

        @Deprecated
        public void setValueAttribute​(java.lang.String newValue)
        Deprecated.
        as of version 3.0.0; use setValue(String) instead
        Sets the content of the value attribute.
        Overrides:
        setValueAttribute in class HtmlInput
        Parameters:
        newValue - the new value
      • setValue

        public void setValue​(java.lang.String newValue)
        Sets the value.
        Overrides:
        setValue in class HtmlInput
        Parameters:
        newValue - the new value
      • setFiles

        public void setFiles​(java.io.File... files)
        Used to specify multiple files to upload.

        We may follow WebDriver solution, once made, see https://code.google.com/p/selenium/issues/detail?id=2239

        Parameters:
        files - the list of files to upload
      • setDirectory

        public void setDirectory​(java.io.File directory)
        Used to specify the upload directory.
        Parameters:
        directory - the directory to upload all files
      • getFiles

        public java.io.File[] getFiles()
        Returns the files.
        Returns:
        the array of Files
      • isValid

        public boolean isValid()
        Returns whether this element satisfies all form validation constraints set.
        Overrides:
        isValid in class HtmlInput
        Returns:
        whether this element satisfies all form validation constraints set