Class FileUploadHandler


  • public class FileUploadHandler
    extends java.lang.Object
    A file upload handler is used to accept file uploads from a client. After creating a file upload handler, the server will accept file uploads to the URL returned by getUploadUrl(). Upload listeners can be attached to react on progress. When the upload has finished, a FileUploadHandler has to be disposed of by calling its dispose() method.
    • Constructor Summary

      Constructors 
      Constructor Description
      FileUploadHandler​(FileUploadReceiver receiver)
      Constructs a file upload handler that is associated with the given receiver.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addUploadListener​(FileUploadListener listener)
      Adds a the given file upload listener to the collection of listeners who will be notified when a file upload proceeds.
      void dispose()
      Closes and de-registers the upload handler.
      long getMaxFileSize()
      Returns the maximum file size in bytes allowed to be uploaded for this handler.
      FileUploadReceiver getReceiver()
      Returns the file upload receiver that is associated with this file upload handler.
      long getUploadTimeLimit()
      Returns the maximum upload duration.
      java.lang.String getUploadUrl()
      Returns the upload URL to which a file can be uploaded.
      void removeUploadListener​(FileUploadListener listener)
      Removes the given file upload listener from the collection of listeners who will be notified when a file upload proceeds.
      void setMaxFileSize​(long maxFileSize)
      Sets the maximum file size in bytes allowed to be uploaded for this handler.
      void setUploadTimeLimit​(long timeLimit)
      Sets the maximum upload duration in milliseconds.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileUploadHandler

        public FileUploadHandler​(FileUploadReceiver receiver)
        Constructs a file upload handler that is associated with the given receiver. The receiver is responsible for reading and processing the uploaded data.
        Parameters:
        receiver - the receiver that should process the uploaded data, must not be null
    • Method Detail

      • getUploadUrl

        public java.lang.String getUploadUrl()
        Returns the upload URL to which a file can be uploaded.
        Returns:
        the encoded upload URL
      • getReceiver

        public FileUploadReceiver getReceiver()
        Returns the file upload receiver that is associated with this file upload handler.
        Returns:
        the associated receiver
      • dispose

        public void dispose()
        Closes and de-registers the upload handler. After calling this method, no subsequent upload requests for this handler will be accepted anymore. Clients must call this method before discarding the instance of the handler to allow it to be garbage collected.
      • getMaxFileSize

        public long getMaxFileSize()
        Returns the maximum file size in bytes allowed to be uploaded for this handler. The default value of -1, indicates no limit.
        See Also:
        setMaxFileSize(long)
      • setMaxFileSize

        public void setMaxFileSize​(long maxFileSize)
        Sets the maximum file size in bytes allowed to be uploaded for this handler. A value of -1 indicates no limit.
        See Also:
        getMaxFileSize()
      • getUploadTimeLimit

        public long getUploadTimeLimit()
        Returns the maximum upload duration. If upload takes longer than this it will be interrupted. The default value of -1, indicates no limit.
        Since:
        3.3
      • setUploadTimeLimit

        public void setUploadTimeLimit​(long timeLimit)
        Sets the maximum upload duration in milliseconds. If upload takes longer than this it will be interrupted. The default value of -1, indicates no limit.
        Since:
        3.3
        See Also:
        getUploadTimeLimit()