|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FileData
This class contains all data and methods for a file to upload. The current
UploadPolicy
contains the necessary parameters
to personalize the way files must be handled.
The JUpload package provides a default implementation of this class in
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.
This class is the interface that all FileData must implement. The
DefaultFileData
class contains the default implementation for this
interface. The PictureFileData
contains another implementation of
this interface, adapted to manage pictures (rotation, resizing...).
The instance of FileData is created by the
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.
Method Summary | |
---|---|
void |
afterUpload()
This function is called after upload, whether it is successful or not. |
void |
appendFileProperties(wjhk.jupload2.upload.helper.ByteArrayEncoder bae,
int index)
Called during the upload, by the FileUploadThread . |
void |
beforeUpload()
Prepare the fileData to upload. |
boolean |
canRead()
Indicate if this file can be read. |
String |
getDirectory()
Get the directory of the file. |
File |
getFile()
Standard getter, for the file described by the FileData instance. |
String |
getFileExtension()
|
long |
getFileLength()
|
String |
getFileName()
Get the original filename. |
InputStream |
getInputStream()
This function creates an InputStream from this file. |
Date |
getLastModified()
|
String |
getMimeType()
This function return the FileData content type. |
String |
getRelativeDir()
Retrieves the path of this file relative to it's root dir |
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. |
Method Detail |
---|
void appendFileProperties(wjhk.jupload2.upload.helper.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() throws JUploadException
PictureFileData
. This method is called before
the upload of this file.
JUploadException
- Encapsulation of the Exception, if any would
occurs.FileUploadThread
long getUploadLength() throws JUploadException
beforeUpload()
and
before the call to afterUpload()
.
JUploadException
- Encapsulation of the Exception, if any would
occurs.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()
String getDirectory()
String getMimeType()
boolean canRead()
File getFile()
String getRelativeDir()
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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |