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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.java.io.File
getUploadDirectory()
Return the directory where the file should be uploaded to, ornull
when a temporary directory is used.void
receive(java.io.InputStream dataStream, FileDetails details)
Reads and processes all data from the provided input stream.void
setUploadDirectory(java.io.File directory)
Set the directory to upload to.
-
-
-
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 classFileUploadReceiver
- Parameters:
dataStream
- the stream to read fromdetails
- 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
-
setUploadDirectory
public void setUploadDirectory(java.io.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 java.io.File getUploadDirectory()
Return the directory where the file should be uploaded to, ornull
when a temporary directory is used.- Since:
- 3.7
-
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 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:
java.io.IOException
-
-