org.eclipse.rap.fileupload

## Class FileUploadHandler

- java.lang.Object
- - org.eclipse.rap.fileupload.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 and Description
`FileUploadHandler(FileUploadReceiver receiver)` Constructs a file upload handler that is associated with the given receiver.

### Method Summary

Methods
`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

#### addUploadListener

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

Parameters:
  `listener` - the file upload listener to add, must not be `null`
See Also:
  `removeUploadListener(org.eclipse.rap.fileupload.FileUploadListener)`

#### removeUploadListener

    public void removeUploadListener(FileUploadListener listener)

Removes the given file upload listener from the collection of listeners who will be notified when a file upload proceeds.

Parameters:
  `listener` - the file upload listener to remove, must not be `null`
See Also:
  `addUploadListener(org.eclipse.rap.fileupload.FileUploadListener)`

#### 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()`

Copyright (c) EclipseSource and others 2002, 2019. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0