public class UploadFileData extends Object implements FileData
Constructor and Description |
---|
UploadFileData(boolean poisonned)
This particular constructor is posted by the
FilePreparationThread in the preparedFileQueue to indicate
that the last file has been prepared. |
UploadFileData(FileData fileDataParam,
int numOfFileInCurrentUpload,
FileUploadManagerThread fileUploadManagerThreadParam,
UploadPolicy uploadPolicyParam)
Standard constructor for the UploadFileData class.
|
Modifier and Type | Method and Description |
---|---|
void |
afterUpload()
Clean any local resources, then transmit to the encapsulated
FileData.afterUpload() . |
void |
appendFileProperties(ByteArrayEncoder bae,
int index)
Called during the upload, by the
FileUploadThread . |
void |
beforeRetry()
Clean any local resources, to allow retrying to upload this file.
|
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.
|
File |
getFile() |
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.
|
int |
getNumOfFileInCurrentUpload() |
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. |
String |
getUploadFilename(int index)
Retrieves the file name, that should be used in the server application.
|
boolean |
getUploadFlag()
The upload floag is not managed here.
|
long |
getUploadLength()
This methods stores locally the upload length.
|
String |
getUploadName(int index)
Retrieves the upload file name, that should be sent to the server.
|
boolean |
isPoisonned() |
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)
The upload floag is not managed here.
|
public UploadFileData(FileData fileDataParam, int numOfFileInCurrentUpload, FileUploadManagerThread fileUploadManagerThreadParam, UploadPolicy uploadPolicyParam)
fileDataParam
- The file data the this instance must transmist.numOfFileInCurrentUpload
- fileUploadManagerThreadParam
- The current instance of FileUploadThread
uploadPolicyParam
- The current upload policy, instance of UploadPolicy
public UploadFileData(boolean poisonned)
FilePreparationThread
in the preparedFileQueue to indicate
that the last file has been prepared.poisonned
- This parameter is here to avoid this constructor to be the default constructor. Its value must
be 'true'.public void afterUpload()
FileData.afterUpload()
.afterUpload
in interface FileData
FileData.afterUpload()
public void beforeRetry()
public 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.appendFileProperties
in interface FileData
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)
public 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.beforeUpload
in interface FileData
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
,
FileData.getRelativeDir()
public boolean canRead()
public String getDirectory()
getDirectory
in interface FileData
public File getFile()
public String getFileExtension()
getFileExtension
in interface FileData
public long getFileLength()
getFileLength
in interface FileData
public String getFileName()
getFileName
in interface FileData
public 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.FileData.isPreparedForUpload()
returns true.getInputStream
in interface FileData
JUploadException
- Encapsulation of the Exception, if any would occurs.public Date getLastModified()
getLastModified
in interface FileData
public String getMD5() throws JUploadException
getMD5
in interface FileData
JUploadException
#beforeUpload()
public String getMimeType()
getMimeType
in interface FileData
public String getRelativeDir()
getRelativeDir
in interface FileData
public String getAbsolutePath()
getAbsolutePath
in interface FileData
public String getUploadFilename(int index) throws JUploadException
index
- The index of this file in the current request to the server.JUploadException
- Thrown when an error occurs.UploadPolicy.getUploadFilename(FileData, int)
public String getUploadName(int index) throws JUploadException
UploadPolicy.getUploadFilename(FileData, int)
method.index
- The index of this file in the current request to the server.JUploadException
UploadPolicy.getUploadName(FileData, int)
public long getUploadLength()
FileData
interface, this method
may be called after afterUpload()
, at one condition: that it has been called once before
afterUpload()
is called.getUploadLength
in interface FileData
FileData.getUploadLength()
public boolean isPreparedForUpload()
#beforeUpload()
, and the to false in the call to FileData.afterUpload()
.isPreparedForUpload
in interface FileData
public boolean isPoisonned()
UploadFileDataPoisonned
public int getNumOfFileInCurrentUpload()
public boolean getUploadFlag()
getUploadFlag
in interface FileData
public void setUploadFlag(boolean uploadFlag)
setUploadFlag
in interface FileData
IllegalArgumentException
- when uploadFlag is false.public TreeFileDataNode getTreeFileDataNode()
FileData
TreeFileDataNode
, from the hierarchical view.getTreeFileDataNode
in interface FileData
public void setTreeFileDataNode(TreeFileDataNode node)
FileData
TreeFileDataNode
, from the hierarchical view. Allows link between the
flat and hierarchical view.setTreeFileDataNode
in interface FileData
Copyright © 2015. All rights reserved.