Package wjhk.jupload2.filedata

This package allows you to change the file relative behaviour: this page describes how to override the default behaviour, to fullfill your needs (for instance add data compression, preload check, new data about files in the upload to the server..

See:
          Description

Interface Summary
FileData This class contains all data and methods for a file to upload.
 

Class Summary
AudioFileData This class contains all data for files to upload an audio file.
DefaultFileData This class contains all data and methods for a file to upload.
PictureFileData This class contains all data about files to upload as a picture.
 

Package wjhk.jupload2.filedata Description

This package allows you to change the file relative behaviour: this page describes how to override the default behaviour, to fullfill your needs (for instance add data compression, preload check, new data about files in the upload to the server..

What is FileData for ?

The FileData interface provides an easy way to add new file type capabilities to the applet. The main entry points allow you to:
  • Change the file behaviour for the upload. For instance: additional checks, compression before upload, new file properties to be sent to the server.
  • New GUI capabilities: for instance an AudioFileData has been started, to allow the user to hear the sound in the files he selected.
  • HowTo create a new FileData instance

    The core/default implementation is contained in DefaultFileData. This class provides a default implementation to all FileData interface methods. The easiest way to create a new FileData instance, is to inherit from this default implementation, and just override the method you're interested in. Doing this minimizes your work, and insures you the minimum risk of incompatibility with next versions.
    Once you've created your new XxxFileData class, you'll have to create objects of this class. This is done by creating a new UploadPolicy, and override the UploadPolicy.createFileData(java.io.File, java.io.File) method.

    Description of FileData methods

    Methods with impact on upload behaviour or content

    FileData.appendFileProperties(ByteArrayEncoder, int) Add properties like the filename, or the directory to the upload (useless in FTP mode)
    FileData.beforeUpload() Allows the FileData to do any necessary work before the upload of the file begin. For instance, in PictureFileData, the picture can here be resized, according to the upload policies values.
    FileData.getUploadLength() Returns the actual number of bytes that will be uploaded. Will be different from the file length, if the file must transformed before upload. For instance: picture resizing, or before upload compression.
    FileData.afterUpload() Called after the end of the upload. Allows to clear any resource, like temporary files.
    FileData.getInputStream() Returns an InputStream, that'll contain all bytes to upload.

    Methods for general file information

    You probably won't have to override these methods.
  • FileData.getFileExtension()
  • FileData.getFileLength()
  • FileData.getLastModified()
  • FileData.getDirectory()
  • FileData.getMimeType()
  • FileData.canRead()
  • FileData.getFile()
  • FileData.getRelativeDir(): Returns the directory, relative to the current selection. Especially useful when dropping entire directories on the applet.