|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwjhk.jupload2.filedata.DefaultFileData
public class DefaultFileData
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.
This class is the default FileData implementation. It gives the default
behaviour, and is used by DefaultUploadPolicy. It provides standard
control on the files choosen for upload.
FileData| Field Summary | |
|---|---|
protected String |
mimeType
Mime type of the file. |
static Properties |
mimeTypes
the mime type list, coming from: http://www.mimetype.org/ Thanks to them! |
(package private) UploadPolicy |
uploadPolicy
The current upload policy. |
| Constructor Summary | |
|---|---|
DefaultFileData(File file,
File root,
UploadPolicy uploadPolicy)
Standard constructor |
|
| Method Summary | |
|---|---|
void |
afterUpload()
This function is called after upload, whether it is successful or not. |
void |
appendFileProperties(wjhk.jupload2.upload.helper.ByteArrayEncoder bae)
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. |
static String |
getExtension(File file)
Returns the extension of the given 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 th actual file length. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
UploadPolicy uploadPolicy
public static Properties mimeTypes
protected String mimeType
| Constructor Detail |
|---|
public DefaultFileData(File file,
File root,
UploadPolicy uploadPolicy)
file - The file whose data this instance will give.root - The directory root, to be able to calculate the result of
getRelativeDir()uploadPolicy - The current upload policy.| Method Detail |
|---|
public void appendFileProperties(wjhk.jupload2.upload.helper.ByteArrayEncoder bae)
throws JUploadIOException
FileUploadThread. The FileData
instance should then call the
ByteArrayEncoder.appendTextProperty(String, String) method to add
each file property to the current upload.
appendFileProperties in interface FileDatabae - The byte encoder, where the properties must be added
JUploadIOException - Encapsulation of the IOException, if any would
occurs.ByteArrayEncoder.appendTextProperty(String, String)
public void beforeUpload()
throws JUploadException
PictureFileData. This method is called before
the upload of this file.
beforeUpload in interface FileDataJUploadException - Encapsulation of the Exception, if any would
occurs.FileUploadThread
public long getUploadLength()
throws JUploadException
getUploadLength in interface FileDataJUploadException - Encapsulation of the Exception, if any would
occurs.PictureFileDatapublic void afterUpload()
PictureFileData.afterUpload() removes the temporary
file, if any was created.
afterUpload 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.
getInputStream in interface FileDataJUploadException - Encapsulation of the Exception, if any would
occurs.public String getFileName()
getFileName in interface FileDatapublic String getFileExtension()
getFileExtension in interface FileDatapublic long getFileLength()
getFileLength in interface FileDatapublic Date getLastModified()
getLastModified in interface FileDatapublic String getDirectory()
getDirectory in interface FileDatapublic String getMimeType()
getMimeType in interface FileDatapublic boolean canRead()
canRead in interface FileDatapublic File getFile()
getFile in interface FileDatapublic String getRelativeDir()
getRelativeDir in interface FileDatapublic static String getExtension(File file)
file - the file whose the extension is wanted!
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||