Package org.eclipse.rap.fileupload
Class DiskFileUploadReceiver
java.lang.Object
org.eclipse.rap.fileupload.FileUploadReceiver
org.eclipse.rap.fileupload.DiskFileUploadReceiver
A file upload receiver that stores received files on disk.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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[]
Returns an array with files that the received data has been saved to.Return the directory where the file should be uploaded to, ornull
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.
-
Constructor Details
-
DiskFileUploadReceiver
public DiskFileUploadReceiver()
-
-
Method Details
-
receive
Description copied from class:FileUploadReceiver
Reads and processes all data from the provided input stream.- Specified by:
receive
in classFileUploadReceiver
- Parameters:
dataStream
- the stream to read fromdetails
- the details of the uploaded file like file name, content-type and size- Throws:
IOException
- if an input / output error occurs
-
getContentType
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
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
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
Return the directory where the file should be uploaded to, ornull
when a temporary directory is used.- Since:
- 3.7
-
createTargetFile
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
Creates a file to save the content-type. Subclasses may override.- Parameters:
uploadedFile
- the file that contains uploaded datadetails
- 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
-