Package org.eclipse.rap.fileupload

# Class DiskFileUploadReceiver

java.lang.Object
org.eclipse.rap.fileupload.FileUploadReceiver
org.eclipse.rap.fileupload.DiskFileUploadReceiver

public class DiskFileUploadReceiver extends FileUploadReceiver
A file upload receiver that stores received files on disk.

## Constructor Summary

Constructors
Constructor
Description
`DiskFileUploadReceiver()`

## Method Summary

Modifier and Type
Method
Description
`protected File`
`createContentTypeFile(File uploadedFile, FileDetails details)`
Creates a file to save the content-type.
`protected File`
`createTargetFile(FileDetails details)`
Creates a file to save the received data to.
`static String`
`getContentType(File uploadedFile)`
Obtains the content type provided by the client when the given file was uploaded.
`File[]`
`getTargetFiles()`
Returns an array with files that the received data has been saved to.
`File`
`getUploadDirectory()`
Return the directory where the file should be uploaded to, or `null` when a temporary directory is used.
`void`
`receive(InputStream dataStream, FileDetails details)`
Reads and processes all data from the provided input stream.
`void`
`setUploadDirectory(File directory)`
Set the directory to upload to.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DiskFileUploadReceiver

public DiskFileUploadReceiver()

## Method Details

### receive

public void receive(InputStream dataStream, FileDetails details) throws IOException
Description copied from class: `FileUploadReceiver`
Reads and processes all data from the provided input stream.

Specified by:
  `receive` in class `FileUploadReceiver`
Parameters:
  `dataStream` - the stream to read from
  `details` - the details of the uploaded file like file name, content-type and size
Throws:
  `IOException` - if an input / output error occurs

### getContentType

public static String getContentType(File uploadedFile)
Obtains the content type provided by the client when the given file was uploaded. This method does not look at the uploaded file contents to determine the content type.

Parameters:
  `uploadedFile` - - the file that was uploaded and handled by an instance of DiskFileUploadReceiver.
Returns:
  the content type of the uploaded file or `null` if the content type could not be found.

### getTargetFiles

public File[] getTargetFiles()
Returns an array with files that the received data has been saved to.

Returns:
  the array with target files or empty array if no files have been stored yet

### setUploadDirectory

public void setUploadDirectory(File directory)
Set the directory to upload to. If none is set, the default directory will be used

Parameters:
  `directory` - the directory to use
Since:
  3.7

### getUploadDirectory

public File getUploadDirectory()
Return the directory where the file should be uploaded to, or `null` when a temporary directory is used.

Since:
  3.7

### createTargetFile

protected File createTargetFile(FileDetails details) throws IOException
Creates a file to save the received data to. Subclasses may override.

Parameters:
  `details` - the details of the uploaded file like file name, content-type and size
Returns:
  the file to store the data in
Throws:
  `IOException`

### createContentTypeFile

protected File createContentTypeFile(File uploadedFile, FileDetails details) throws IOException
Creates a file to save the content-type. Subclasses may override.

Parameters:
  `uploadedFile` - the file that contains uploaded data
  `details` - the details of the uploaded file like file name, content-type and size
Returns:
  the file to store the content-type data in
Throws:
  `IOException`