|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wjhk.jupload2.upload.UploadFileData
public class UploadFileData
This class implements the FileData interface, and is responsible to do the actual upload of the files.
Constructor Summary | |
---|---|
UploadFileData(FileData fileDataParam,
FileUploadManagerThread fileUploadThreadParam,
UploadPolicy uploadPolicyParam)
Standard constructor for the UploadFileData class. |
Method Summary | |
---|---|
void |
afterUpload()
This method closes the inputstream, and remove the file from the filepanel. |
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()
|
(package private) 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 it's root dir |
(package private) long |
getRemainingLength()
Get the number of files that are still to upload. |
String |
getUploadFilename(int index)
Retrieves the file name, that should be used in the server application. |
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 |
isPreparedForUpload()
Indicates whether the file can be uploaded or not. |
(package private) void |
uploadFile(OutputStream outputStream,
long amount)
This methods writes the file data (see FileData.getInputStream()
to the given outputStream (the output toward the HTTP server). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UploadFileData(FileData fileDataParam, FileUploadManagerThread fileUploadThreadParam, UploadPolicy uploadPolicyParam)
fileDataParam
- The file data the this instance must transmist.fileUploadThreadParam
- The current instance of
FileUploadThread
uploadPolicyParam
- The current upload policy, instance of
UploadPolicy
Method Detail |
---|
long getRemainingLength()
FileData.getUploadLength()
.
getInputStream()
String getMD5() throws JUploadException
JUploadException
void uploadFile(OutputStream outputStream, long amount) throws JUploadException, JUploadInterrupted
FileData.getInputStream()
to the given outputStream (the output toward the HTTP server).
outputStream
- The stream on which the data is to be written.amount
- The number of bytes to write.
JUploadException
- if an I/O error occurs.
JUploadInterrupted
- Thrown when an interruption of the thread is
detected.public void afterUpload()
FileData.afterUpload()
.
afterUpload
in interface FileData
FileData.afterUpload()
public 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.
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() throws JUploadException
PictureFileData
. This method is called before
the upload of this file.
beforeUpload
in interface FileData
JUploadException
- Encapsulation of the Exception, if any would
occurs.FileUploadThread
public boolean canRead()
canRead
in interface FileData
public String getDirectory()
getDirectory
in interface FileData
public File getFile()
getFile
in interface FileData
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 getMimeType()
getMimeType
in interface FileData
public String getRelativeDir()
getRelativeDir
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() throws JUploadException
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
JUploadException
- Encapsulation of the Exception, if any would
occurs.FileData.getUploadLength()
public boolean isPreparedForUpload()
FileData.beforeUpload()
, and the to false in
the call to FileData.afterUpload()
.
isPreparedForUpload
in interface FileData
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |