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 and Description
`DiskFileUploadReceiver()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected java.io.File` `createContentTypeFile(java.io.File uploadedFile, FileDetails details)` Creates a file to save the content-type.
`protected java.io.File` `createTargetFile(FileDetails details)` Creates a file to save the received data to.
`static java.lang.String` `getContentType(java.io.File uploadedFile)` Obtains the content type provided by the client when the given file was uploaded.
`java.io.File[]` `getTargetFiles()` Returns an array with files that the received data has been saved to.
`void` `receive(java.io.InputStream dataStream, FileDetails details)` Reads and processes all data from the provided input stream.

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

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

### Constructor Detail

#### DiskFileUploadReceiver

    public DiskFileUploadReceiver()

### Method Detail

#### receive

    public void receive(java.io.InputStream dataStream,
                        FileDetails details)
                 throws java.io.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:
  `java.io.IOException` - if an input / output error occurs

#### getContentType

    public static java.lang.String getContentType(java.io.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 java.io.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

#### createTargetFile

    protected java.io.File createTargetFile(FileDetails details)
                                     throws java.io.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:
  `java.io.IOException`

#### createContentTypeFile

    protected java.io.File createContentTypeFile(java.io.File uploadedFile,
                                                 FileDetails details)
                                          throws java.io.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:
  `java.io.IOException`

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