public interface FileData
UploadPolicy
contains the necessary parameters to personalize the way files must be
handled. DefaultFileData
. This default
implementation contains all necessary methods to allow upload. You can override it to add new file behaviour. For
instance, you could add a XMLFileData, that would check that XML is valid before upload. See the package summary for more details about that. DefaultFileData
class contains the default
implementation for this interface. The PictureFileData
contains another implementation of this interface,
adapted to manage pictures (rotation, resizing...). UploadPolicy#createFileData(File, File)
method. This method can be
overrided in a new upoad policy, to create an instance of another FileData. See PictureFileData
for an
example about FileData customization.Modifier and Type | Method and Description |
---|---|
void |
afterUpload()
This function is called after upload, whether it is successful or not.
|
void |
appendFileProperties(ByteArrayEncoder bae,
int index)
Called during the upload, by the
FileUploadThread . |
void |
beforeUpload(String uploadFileRoot)
Prepare the fileData to upload.
|
boolean |
canRead()
Indicate if this file can be read.
|
String |
getAbsolutePath()
Returns the absolute path, as it will be sent during the upload.
|
String |
getDirectory()
Get the directory of the file.
|
String |
getFileExtension() |
long |
getFileLength() |
String |
getFileName()
Get the original filename.
|
InputStream |
getInputStream()
This function creates an InputStream from this file.
|
Date |
getLastModified() |
String |
getMD5()
Retrieves the MD5 sum of the file.
|
String |
getMimeType()
This function return the FileData content type.
|
String |
getRelativeDir()
Retrieves the path of this file relative to the root directory
|
TreeFileDataNode |
getTreeFileDataNode()
Links this FileData to the associated
TreeFileDataNode , from the hierarchical view. |
boolean |
getUploadFlag()
Indicates whether the check box is checked or not.
|
long |
getUploadLength()
Get size of upload, which may be different from the actual file length.
|
boolean |
isPreparedForUpload()
Indicates whether the file can be uploaded or not.
|
void |
setTreeFileDataNode(TreeFileDataNode node)
Setters for the to the associated
TreeFileDataNode , from the hierarchical view. |
void |
setUploadFlag(boolean uploadFlag)
Allows to set or unset the upload flag.
|
void appendFileProperties(ByteArrayEncoder bae, int index) throws JUploadIOException
FileUploadThread
. The FileData instance should then call the
ByteArrayEncoder.appendTextProperty(String, String, int)
method to add each file property to the current
upload.bae
- The byte encoder, where the properties must be addedindex
- Index of the file concerned by this value. -1 if this is a global parameter.JUploadIOException
- Encapsulation of the IOException, if any would occurs.ByteArrayEncoder.appendTextProperty(String, String, int)
void beforeUpload(String uploadFileRoot) throws JUploadException
PictureFileData
. This method is called before the upload of this file. If no exception is thrown, then
the file is correctly prepared.uploadFileRoot
- The biggest path which is common to all uploaded files. Used to calculate the relativeDir
to this root path, for each file. This relative path is sent as metadata during the uploadJUploadException
- Encapsulation of the Exception, if any error would occurs.FileUploadThread
,
getRelativeDir()
long getUploadLength()
#beforeUpload()
and before the call to afterUpload()
.PictureFileData
void afterUpload()
PictureFileData.afterUpload()
removes the temporary file, if any
was created.InputStream getInputStream() throws JUploadException
FileUploadThread
class then reads bytes from it
and transfers them to the webserver. The caller is responsible for closing this stream.isPreparedForUpload()
returns true.JUploadException
- Encapsulation of the Exception, if any would occurs.IllegalStateException
- When the upload is not prepared (before a call to #beforeUpload()
or after
a call to afterUpload()
String getFileName()
String getFileExtension()
long getFileLength()
Date getLastModified()
boolean getUploadFlag()
void setUploadFlag(boolean uploadFlag)
String getDirectory()
String getMD5() throws JUploadException
JUploadException
#beforeUpload()
String getMimeType()
boolean canRead()
String getRelativeDir()
String getAbsolutePath()
boolean isPreparedForUpload()
#beforeUpload()
, and the to false in the call to afterUpload()
.IllegalStateException
- When the upload is not prepared (before a call to #beforeUpload()
or after
a call to afterUpload()
TreeFileDataNode getTreeFileDataNode()
TreeFileDataNode
, from the hierarchical view.void setTreeFileDataNode(TreeFileDataNode node)
TreeFileDataNode
, from the hierarchical view. Allows link between the
flat and hierarchical view.Copyright © 2015. All rights reserved.