wjhk.jupload2.policies
Interface UploadPolicy

All Known Implementing Classes:
CoppermineUploadPolicy, CustomizedNbFilesPerRequestUploadPolicy, DefaultUploadPolicy, FileByFileUploadPolicy, FilesTogetherUploadPolicy, PictureUploadPolicy

public interface UploadPolicy

This package contains upload policies, which allow easy configuration of the applet behavior.

The class DefaultUploadPolicy contains a default implementation for all UploadPolicy methods.

Parameters

Here is the list of all parameters available in the current package, that is: available in available upload policies. These are applet parameters that can be 'given' to the applet, with tags, as explained below in the example.

Let's start with some hints:

  • debugLevel and showLogWindow: I recommend putting debugLevel to 99 and showLogWindow to onError.
  • maxFileSize: this prevents the user to upload too big files. The value depends on your needs.
  • maxChunkSize: allows you to override the server's maximum upload file size. The uploaded file will be split in pieces of maxChunkSize bytes. Then, it's up to you to concatenate the file pieces, into a server script. There are sample in this doc, and in the JUpload wiki. Please add your samples also...
  • Parameter name Default value /
    Implemented in
    Description
    afterUploadTarget
    Since 2.9.2rc4
    _self

    DefaultUploadPolicy
    This parameter allows to select a specific target frame when redirecting to afterUploadURL. The following values are possible:
    • _self - Show in the window and frame that contain the applet.
    • _parent - Show in the applet's parent frame. If the applet's frame has no parent frame, acts the same as _self.
    • _top - Show in the top-level frame of the applet's window. If the applet's frame is the top-level frame, acts the same as _self.
    • _blank - Show in a new, unnamed top-level window.
    • name - Show in the frame or window named name. If a target named name does not already exist, a new top-level window with the specified name is created, and the document is shown there.
    See also: AppletContext.showDocument(java.net.URL, java.lang.String)
    afterUploadURL null
    since 2.9.0
    DefaultUploadPolicy
    This parameter is used by all policies. It allows the applet to change the current page to another one after a successful upload.
    This allows, for instance, to display a page containing the file description of the newly uploaded page. Since version 3.0.2b2, you can specify a JavaScript expression instead of a plain URL. So afterUploadURL can now contain:
    • A javascript expression: The URL must start by javascript:. See below for details.
    • A http URL: the navigator will open this URL, in the current page or another, according to the afterUploadTarget parameter. Any URL that doesn't start by javascript: is handled as an http URL.
    If the value of afterUploadURL starts with the string "javascript:", the remainder of the string is evaluated as JavaScript expression in the current document context. For example: If afterUloadURL is
    "javascript:alert('Thanks for the upload');",
    then after a successful upload, a messagebox would pop up. Since 3.0.2b3 there are now three place holders available which can be used as parameters in function calls:
    • %success% is replaced by true or false depending on upload success.
    • %msg% is replaced by an unquoted string, containing the error message received from the server (if any). Inside that string, all occurrences of the single-quote character (hex 27) are quoted by backslashes.
    • %body% is replaced by an unquoted string, containing the complete response body. Inside that string, all occurrences of the single-quote character (hex 27) are quoted by backslashes.
    So if you set afterUloadURL to "javascript:alert('%body%');", then the resulting message box will show the body content of the last server response.
    albumId -1

    CoppermineUploadPolicy
    This parameter is only used by CoppermineUploadPolicy. So it is to be used to upload into a coppermine picture gallery. This parameter contains the identifier of the album, where pictures should be used. See CoppermineUploadPolicy for an example.
    Before upload, CoppermineUploadPolicy. CoppermineUploadPolicy.beforeUpload() checks that the albumId is correct, that is: >=1.
    allowedFileExtensions empty string
    since 2.9.0
    DefaultUploadPolicy
    This parameter allows the caller to specify a list of file extension. If this parameter is specified, only file with this extension can be selected in the applet.
    This parameter must contains a list of extensions, in lower case, separated by slashes. eg: jpg/jpeg/gif
    allowHttpPersistent false
    since 3.0.0rc1
    DefaultUploadPolicy
    This parameter allows to switch off persistent HTTP connections which are enabled by default (and the protocol version allows it). Currently, we encountered problems with persistent connections when testing on a windows box using a loopback interface only.
    Note: default value changed to false in 4.0 version.
    browsingDirectory null
    since 4.0.0b2
    DefaultUploadPolicy
    This parameter allows to control the starting browsing directory, that is, the directory the is the current one when the file chooser is open.
    Notes:
      If the directory doesn't exist, or can not be read, a warning is written on the local log window (visible only in debug mode), and this parameter is ignored.
        This directory may begin with ~/ or ~\, to have a path set relative to the current user's home.
    debugLevel 0

    DefaultUploadPolicy
    With 0, you get the normal production output. The higher the number is, the more information is displayed in the log window. Here are some hints about debug level values (please note that this is indicative ... including for me, as I'me writing this during 3.3.2 release:
  • 0: No debug output. Only INFO and ERROR
  • 10: Structural debug output (entering method, exception info...)
  • 30: Details about method parameters
  • 50: Details about internal method variables.
  • 70: Details about encoding toward the server
  • 80: Details about server's response
  • 90: Details about query and server response when sending debug output to urlToSendErrorTo
  • 100: Maximum output information level. The redirection toward afterUploadURL is blocked
  • >100: Additional things for internal debug, like some wait in the code to check what messages the applet displays, while uploading small files on localhost.

  • Note: All debug messages are stored in a temporary log file. This can be used to display more information, if needed. See also the urlToSendErrorTo applet parameter.
    fileChooserIconFromFileContent 0
    since 3.1.0b
    UploadPolicy
    This parameter allows to control whether the file icons in the file chooser are calculated from the file content. This is currently only available for pictures.
    If activated, the file chooser will open each pictures, and calculate the icon by resizing the picture. This is done in by using thread of minimam priority, to minimize performances impact on the navigator. Available values are:
  • -1: disabled. The default system are used.
  • 0 (default): available only in picture mode. That is: the current upload policy is an instance of or a class inheriting from PictureUploadPolicy
  • 1: available for all upload policies.
  • fileChooserIconSize 20
    since 3.1.0b
    UploadPolicy
    This parameter allows to control the size of icons, in pixels, in the file chooser. Used only when fileChooserIconFromFileContent is activated.
    Note: The standard icon size is a value of 20. With 50, you'll get a better view of the picture.
    fileChooserImagePreview true
    since 3.1.0b
    PictureUploadPolicy
    This parameter allows to control whether an preview is available for picture in the file chooser. If activated, the file chooser will open the preview in a separate thread, of high priority. This avoid blocking the applet while calculating the preview picture, when the user just double-clicked a picture file. This parameter is ignored for DefaultUploadPolicy.
    filenameEncoding null

    DefaultUploadPolicy
    Since 3.3.0, this parameter is no more used. The full applet upload HTTP request to the server is now correctly encoded.
    With null, the filename in the Content-Disposition header is not encoded. If not null, the applet tries to encode this filename with the given encoding. It's up to the receiver (the web site) to decode this encoding (see getUploadFilename(FileData, int).
    Example: if the "UTF8" encoding is chosen, the PHP function urldecode can be used to decode the filename.
    formdata null

    DefaultUploadPolicy
    Since 2.9.2rc4
    With this parameter, the name of a HTML form can be specified. If the specified form exists in the same document like the applet, all all form-variables are added as POST parameters to the applet's POST request.
    Note: Whatever value is in the httpUploadParameterType applet parameter, these parameters with the name of the given input in the form. That is: if you have an input text named 'myText', there will be one myText parameter in the HTTP upload request, with the text/plain mime type, and whose value is the content of this field, in the form.
    ftpCreateDirectoryStructure false
    since 4.2.0
    UploadPolicy
    This parameter allows to control whether the directory structure on the client side must be created on the server side.
    Example: if the user upload the test/ directory, which contains the readme.txt file. With ftpCreateDirectoryStructure to false (or default value), the readme.txt is uploaded in the postURL directory. If set to true, the test/ folder is created as a subfolder of the path given in the postURL directory, and the readme.txt is uploaded in this subfolder.
    Note: in HTTP upload, the pathinfo and relpathinfo allows the server side script to manage this directory structure.
    ftpTransfertBinary true
    since 4.1.0
    UploadPolicy
    This parameter allows to control whether the upload should be done in binary or ascii mode. Default is to upload in binary mode.
    ftpTransfertPassive true
    since 4.1.0
    UploadPolicy
    This parameter allows to control whether the upload should be done in FTP passive mode, or in active mode (where the FTP server opens a connection to the client, to do the upload). Default passive mode.
    highQualityPreview false

    DefaultUploadPolicy
    If this parameter is set to true, the applet will call the BufferedImage.getScaledInstance(), instead of doing a basic scale transformation. This consume more CPU: on a PII 500MHz, the full screen go from around 5 seconds to between 12 and 20 seconds, for a picture created by my EOS20D (8,5M pixels). The standard preview (above the file list) seem to be displayed at the same speed, whatever is the value of this parameter.
    Note: when resizing is done before upload, the BufferedImage.getScaledInstance() is always called, so that the uploaded picture is of the best available quality.
    httpUploadParameterName File

    DefaultUploadPolicy
    since 4.5.0
    Contains the parameter name, that will be used to send the file in the HTTP upload request. The default value (File), associated with the default value for httpUploadParameterType (see below), makes all file be uploaded with name from File0 to FileN (when there are N+1 file to upload).
    Put another value, of your server part script need a particular parameter name to work properly.
    Note: valid characters for this parameter are: first letter (letter or number), next letters (letter, number or underscore)
    httpUploadParameterType iteration

    DefaultUploadPolicy
    since 4.5.0
    Allowed values are:
  • iteration: Used to have the attribute property that actually contains the file be named File0 to FileN (if you have N+1 uploaded files). This is the default behavior. In this case, your server script should look for POST properties, named 'File0' to 'FileN'
  • array: Used if your server script want to receive one array, that will contain all uploaded files.
  • oneFile: Indicates that, in the HTTP upload request, there will be only one file. This value is only valid when nbFilesPerRequest is 1. The parameters in the HTTP upload request are let untransformed. For instance, if httpUploadParameterName is the default value (File), the file content will be loaded under the HTTP parameter 'File' (not File0 or File[]).

  • Note: All parameters common to all pictures are sent directly. For instance, if toto is given on the URL, the toto parameter is sent as is (no toto0 for iteration or toto[] for array). Also, if you use the formdata applet parameter, these parameters are sent as is (no 0 or [] added to the parameter name).
    keepOriginalFileExtensionForConvertedImages false is only relevant, if targetPictureFormat is specified.
    • false (default):
      If you upload the file 'test.png' and it is converted to 'jpg', the fileextension will be changed, so that the server will receive this filename: 'test.jpg'
    • true:
      If you upload the file 'test.png' and it is converted to 'jpg', the fileextension will NOT be changed, so that the server will receive the original filename: 'test.png'
    lang Navigator language

    DefaultUploadPolicy
    Should be something like en, fr... Currently only French and English are known from the applet. If anyone want to add another language ... Please translate the wjhk.jupload2.lang.lang_en, and send it back to .
    lookAndFeel
    since 2.5
    empty

    DefaultUploadPolicy
    This allows to control the look & feel of the applet. The authorized values are:
    • empty: uses the default look & feel. This is the same as java.
    • java: uses the java default look & feel. Same as empty.
    • system: uses the current system look and feel. The call will be :
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    • Any valid String argument for UIManager.setLookAndFeel(String).
    maxChunkSize
    Since 2.7.1
    0
    Long.MAX_VALUE

    DefaultUploadPolicy
    This parameters defines the maximum size of an upload.
    • If not set, or set to a value of 0 or less, the chunk mode is disabled. That is: each file will be uploaded within being split in pieces.
    • If set to a value of 1 or more, the upload size will be never be more than maxChunkSize. A file bigger will be split in several part of maxChunkSize size, then the last part will contain the remaining, and will probably be smaller than maxChunkSize.

    How to build the server part: the server will have to 'guess' that the file is split, and then it will have to reconstruct the uploaded file. Here are the necessary informations:
    • When a file is chunked, the jupart and jufinal parameter are given in the URL (get parameters). This identify a chunk upload. If these parameters are not given, the file(s) is(are) uploaded in one piece.
    • jupart identify the part number: from 1 to N for a file being split in N pieces. The N-1 chunks should be maxChunkSize bytes long. The last one contains the remaining of the file.
    • jufinal is set to 0 for chunks from 1 to N-1. It is is set to 1 only for the last chunk (N, in this 'example').
    • The uploaded filename is not modified when the upload is chunked. Example: upload of the file bigPicture.jpeg, of 4,5 Mb, with chunk of 2Mb. The upload is split in three chunk. Chunk 1 and 2 are 2Mb long. The third one is 0,5Mb long. The uploaded filename for these three uploads is bigPicture.jpeg. It's up to the server part to read the jupart and jufinal get parameters, to understand that the upload is chunked.
    • Important: The server script must check the resulting filesize. If not, the client can send a file of any size, and fill the server hard drive.
    • The wwwroot/pages/parseRequest.jsp is a java example of a server page that can receive chunk upload. It stores each chunk is filename.partN (where N is the chunk number), then construct the final file, by concatenating all parts together.
    Note: If nbFilesPerRequest is different than 1, the applet will try to upload the files until the sum of their content length is less than maxChunkSize. The upload is triggered just before the sum of their content length is bigger then maxChunkSize.
    If one file is bigger than maxChunkSize, all previous files are uploaded (at once or not, depending on nbFilesPerRequest). Then the 'big' file is uploaded alone, split in chunk. Then upload goes on, file by file or not, depending on nbFilesPerRequest.
    maxFileSize
    Since 2.7.1
    0
    Long.MAX_VALUE

    DefaultUploadPolicy
    This parameter identify the maximum size that an uploaded file may have. It prevent the user to upload too big files. It is especially important when chunk upload is activated (see below maxChunkSize).
    • If maxChunkSize is not set, negative or 0, maxFileSize should be the maximum upload size of the server. In this case, it is useful only to display a message when the user select a file that will be refused by the server.
    • If chunk upload is activated, this parameter becomes really important: in this case the maximum file size of an uploaded file is ... the available space on the server hard drive! (see below, maxChunkSize).
    maxPicHeight Since 3.3.0: Integer.MAX_VALUE
    (was -1)

    PictureUploadPolicy
    This parameters allows the HTML page to control the maximum height for pictures. If a picture is to be download, and its height is bigger, the picture will be resized. The proportion between width and height of the resized picture are the same as those of the original picture. If both maxPicHeight and maxPicWidth are given, it can happen that the resized picture has a height lesser than maxPicHeight, so that width is no more than maxPicWidth.
    Precisions:
    If this parameter value is negative or 0, then no control is done on the picture height.
    If the original picture is smaller than the maximum size, the picture is not enlarged.
    If the picture is resized, its other characteristics are kept (number of colors, ColorModel...). The picture format is kept, if targetPictureFormat is empty. If the picture format is a destructive (like jpeg), the maximum available quality is chosen.
    See also maxPicWidth, realMaxPicHeight
    maxPicWidth Since 3.3.0: Integer.MAX_VALUE
    (was -1)

    PictureUploadPolicy
    Same as maxPicHeight, but for the maximum width of the uploaded picture.
    See also maxPicHeight, realMaxPicWidth
    nbFilesPerRequest 1 since 4.3.0
    (was -1)

    DefaultUploadPolicy
    This allows the control of the maximal number of files that are uploaded in one HTTP upload to the server.
    If set to -1, there is no maximum. This means that all files are uploaded in the same HTTP request.
    If set to 5, for instance, and there are 6 files to upload, there will be two HTTP upload request to the server : 5 files in the first one, and that last file in a second HTTP request.
    pictureCompressionQuality 0.8
    since 3.1.0
    PictureUploadPolicy
    This parameter controls the picture compression quality, when writing the picture file. 1 means high quality picture, but big files. 0 means poor quality pictures, but small files. 0.8 is a good compromise for the web.
    It is different from the highQualityPreview, which controls the way picture are resized in memory.
    This parameter is currently applied only to jpg (and jpeg) pictures.
    pictureTransmitMetadata false since 3.3.0
    (was true before)

    since 3.2.0
    PictureUploadPolicy
    This parameter controls whether the applet transmit metadata of the original picture. This may prevent personal information to be thrown on the net.
    Note 1: This parameter is especially important for picture coming from the Canon EOS 20D, 30D and 40D: pictures shooted in portrait mode contain metadata that are incompatible with Java 1.6.0_3! The colors of transformed pictures become strange... Since 3.3.0: default to false, to avoid this annonying (and currently not explained) problem.
    Note 2: As of 3.2.0, this parameter blocks metadata only for pictures that are updated by the applet. Metadata from picture transmitted 'as is' are not removed. This is corrected in 3.3.0.
    postURL null since 1.9.2rc4, (was Mandatory before)

    DefaultUploadPolicy
    This parameter specifies the target URL toward which the files should be uploaded. Since version 1.9.2rc4 this parameter is not mandatory anymore. Instead, if omitted or a relative URL is given, the resulting URL is constructed from the applet's DocumentBaseURL. This means, that if the applet tag is dynamically constructed from a PHP script without specifying postURL, the same same script receives the subsequent POST request(s). If this URL may change during the applet execution time, you can call the setProperty applet method from javascript, or create a new UploadPolicy class and either : Note 1: in HTTP, the upload is done in the same user session, as the applet uses the cookies from the navigator. This allows right management during upload, on the server side.
    Note 2: in FTP, you can't use path that contain spaces. Filename may contain spaces. Note 5: in HTTP, the applet use the current Java parameter to connect to the host. By default, this configuration is to use the navigator configuration. So, if a proxy is configured in the navigator network configuration, the applet should use it automatically.
    Note 3: FTP URL should looks like: ftp://username:password@myhost.com:21/directory
    Note 4: in FTP, you'll have to add the jakarta-commons-oro.jar and jakarta-commons-net.jar jar files in the applet ARCHIVE tag attribute. See the 'advanced_js_demo.html page for a sample. You'll have to put the two files coming from the JUpload distribution in the same directory as the wjhk.jupload.jar.
    Note 5: in FTP, you can use the user default folder by putting no folder. The URL can be: ftp://user:mdp@host
    readCookieFromNavigator Since 4.3.0: Boolean
    (true)

    DefaultUploadPolicy
    Since v2.8.1
    If true (default), the applet read cookies from the navigator, with the javascript document.cookie value. If false, the caller should put the relevant 'Cookie' header in the specificHeaders applet parameter. This allows to override any javascript cookie access restriction.
    readUserAgentFromNavigator Since 4.6.1rc2: Boolean
    (true)

    DefaultUploadPolicy
    If true (default), the applet read the userAgent from the navigator, with the javascript document.userAgent value. If false, the caller can put the relevant userAgent header in the specificHeaders applet parameter.
    realMaxPicHeight Since 3.3.0: Integer.MAX_VALUE
    (was -1)

    PictureUploadPolicy
    Since v2.8.1
    This parameters is about the same as maxPicHeight. It overrides it for pictures that must be transformed (currentlty only when the picture is rotated).
    The aim of this parameter, is to prevent the applet to resize picture, and let the server do it: it will be much quicker.
    This allows you to:
    • Put a 'big' maxPicHeight (or don't provide the parameter in the APPLET tag), and let the server resize the picture according to the real maxPicHeight. The maxPicHeight will be used when the picture is not tranformed by the user.
    • Put this realMaxHeight to the real configured maxPicHeight. The applet will then directly produce the final file, when it has to tranform the picture (picture rotation, for instance).

    See also maxPicHeight, realMaxPicWidth, maxChunkSize (to override any server upload size limitation).
    realMaxPicWidth Since 3.3.0: Integer.MAX_VALUE
    (was -1)

    PictureUploadPolicy
    Since v2.8.1
    Same as realMaxPicHeight, but for the maximum width of uploaded picture that must be transformed.
    See also maxPicWidth, realMaxPicHeight
    serverProtocol null since 2.9.2rc4
    (before: "HTTP/1.1")

    DefaultUploadPolicy
    This parameter allows the control of the protocol toward the server. It can be HTTP/0.9 (not tested), HTTP/1.0, HTTP/1.1 and FTP. HTTP supports https. Since version 2.9.2rc4, the default is null, introducing a new facility of automatically adjusting the protocol according to the server response.
    This parameter is really useful only in CoppermineUploadPolicy, as the coppermine application also controls that the requests send within an HTTP session uses the same HTTP protocol (as a protection to limit the 'steal' of session cookies).
    showLogWindow
    Since 3.0.2
    Changed in 3.5.0
    true

    DefaultUploadPolicy
    This parameter was formerly known as showStatusBar which now has a different purpose.
    Since 3.5.0: Available values are (case sensitive):
  • true: always visible.
  • false: always hiden.
  • onError: the log window is hidden. It will be displayed when an error occurs. If you put 99 into the debugLevel, then the full debugOutput become visible if and only if an error occurs

  • Until 3.4.2, it works this way: If given with the False value, the log window will be hidden. The applet will still store all debug information in it. But the user won't see it any more. If a problem occurs, the urlToSendErrorTo can still be used to log all available information.
    showStatusBar True

    New meaning since 3.0.2
    DefaultUploadPolicy
    This parameter controls if the status bar is shown in the applet. If shown, the stausbar provides information about the current transfer speed and estimated time of completion. Before version 3.0.2, this parameter was used to control visibility of the log window. This is now controlled by showLogWindow.
    specificHeaders null

    Since 3.0.2
    DefaultUploadPolicy
    Allows the caller to add any header(s) to the applet. These headers will be sent with each HTTP request to the server. If you put several lines in this parameter, these parameter should be separated by the "\n" string (not the LineFeed character, but the antislash character followed by the n character, like msg="\\n";). No "\n" at the end: it will be added by the applet. In PHP, put '\n', and not "\n" (See PHP doc, on strings)
    This allows an easy management of Basic HTTP authentication. Just add a header like this one:
    Authorization: Basic Base64EncodedString Where Base64EncodedString is the string "login:passord" encoded in Base 64.
    sslVerifyCert
    Since 3.0.2b1
    none
    DefaultUploadPolicy
    With this parameter, the handling of certificates when using SSL can be configured. There are 4 possible settings:
    • none (default): Any server cert is accepted, no cert-based client authentication is performed.
    • server: The server cert is verified against the local truststore and if that fails, a dialog pops up which asks the user if the certificate shall be accepted permanently, just for the current session or not at all (Just like any browser would do).
    • client: A user-certificate (which must be available in the local keystore) is used to perform client authentication.
    • strict: The combination of client and server.

    The location of the local truststore and keystore uses the normal JRE conventions. This means, that the system truststore is used for verifying server certs (usually in $JAVA_HOME/lib/security/cacerts) unless either the system property javax.net.ssl.trusStore specifies another location or a file .truststore exists in the user's home directory. If the user decides to permanently accept an untrusted certificate, the file .truststore in the user's home directory is written. The default keystore (for client certificates) is the file .keystore in the user's home directory. This can be overridden by setting the system property javax.net.ssl.keyStore. If the name of the keystore ends in .p12, it is assumed that the keystore is in PKCS12 format, otherwise the default format as specified in the JRE security-configuration is used.

    Important Note about client authentication:

    At the time of this writing, a serious bug exists in apache 2.0.x which prevents POST requests when SSL renegotiation is about to happen. Renegotiation is triggered by a location-based (or directory-based) change of the SSLVerifyClient directive in apache. Therefore you can not protect a sub-area of an otherwise unprotected SSL server. You can circumvent that by setting up a virtualhost which is configured to perform SSL client verification for the complete virtualhost. Attached to the bug report at ASF Bugzilla, there are several patches which claim to fix the problem. However in that same report, other users complain about those patches to be ineffective. Therefore, the author recommends avoiding re-negotiation alltogether by using the virtualhost aproach described above. It is the understanding of the author, that this bug has been fixed for apache 2.2, however the author did not verify that. Test-Reports from users running apache 2.2 are welcome.

    storeBufferedImage false
    Deprecated
    PictureUploadPolicy
    This parameter indicates that the preview image on the applet is kept in memory. It works really nice under eclise. But, once in the navigator, the applet runs very quickly out of memory. So I add a lot of calls to PictureFileData.freeMemory(String, UploadPolicy) , but it doesn't change anything. Be careful to this parameter, and let it to the default value, unless you've well tested it under all your target client configurations.
    This parameter will probably never be correctly implemented.
    stringUploadError Since 3.2.0: "^ERROR: (.*)$" for all upload policies
    Empty string ("") [if using DefaultUploadPolicy]
    "ERROR: (.*)" [if using CopperminUploadPolicy]

    DefaultUploadPolicy
    Since 2.9.2rc4
    This string is a regular expression. It allows the applet to test that the server has detected an error in the upload. If this parameter is given to the applet, the upload thread will try to match this regular expression against each line of the server response body. If a group is found, it is considered as the error message, and will be displayed to the user.
    If the match is successfull once, the upload is considered to have failed. and JUploadExceptionUploadFailed is thrown. If the expression contains a hunt-group, the matching contents of that group is reported to the user. For example: If let the default value "^ERROR: (.*)$" here, the applet will find an error if at least one line returned in the server response begins with "ERROR: ". Then, all characters that follow are extracted as the error message. So, if the server response contains the line "ERROR: md5sum check failed", the string "md5sum check failed" is used for the exception message. But if it returns a line "maybe ERROR: is it an error?", then the applet won't find any error in the server response.
    Note: you can put line breaks in the error message. The message must be in one line in the HTTP response. To display a line break to the user, just put the two characters \n in the http response (would be a "\\n" in java or PHP).
    stringUploadSuccess "^SUCCESS$"
    empty string ("") since 2.9.0
    (was ".* 200 OK$" before)

    DefaultUploadPolicy
    This string is a regular expression. It allows the applet to test that the server has accepted the upload. If this parameter is given to the applet, the upload thread will try to match this regular expression against each lines returned from the server.
    If the match is successfull once, the upload is considered to be a success. If not, a JUploadExceptionUploadFailed is thrown.
    The default test expression testes that the web server returns no HTTP error: 200 is the return code for a successfull HTTP request. It actually means that postURL is a valid URL, and that the applet was able to send a request to this URL: there should be no problem with the network configuration, like proxy, password proxy...).
    But it doesn't mean that the uploaded files have correctly be managed by the server. For instance, the URL can be http://sourceforge.net, which, of course, would not take your files into account.
    So, as soon as you know a regular expression that test the return from the target application (and not just a techical HTTP response code), change the stringUploadSuccess to this value. For instance, the default value will be matched if the HTTP body content of the server response contains one line that is exactly 'SUCCESS', without any other character. This 'success' means that the pictures have correctly uploaded to the server, and that he successfully managed the uploaded files.
    stringUploadWarning "^WARNING: (.*)$"
    DefaultUploadPolicy
    Since 3.4.2
    This string is a regular expression. It allows the applet to test that the server has detected a warning was generated by the server. This warning is just a warning, that will be displayed to the user, as is. There may be several warnings in the server return. If one or more warning is/are received, the message(s) will be displayed to the user.
    If the expression contains a hunt-group, the matching contents of that group is reported to the user. For example: If you let the default value "^WARNING: (.*)$" here, the applet will find an error if at least one line returned in the server response begins with "WARNING: ". Then, all characters that follow are extracted as the error message. So, if the server response contains the line "WARNING: Bad encoding", the string "Bad encoding" is displayed as warning message to the user. But if it returns a line "maybe WARNING: is it an error?", then the applet won't find any warning in the server response.
    Notes:
  • There is no link between these warning and the fact the upload is considered to be a success or not. Upload success is only based on the success and error string. See the stringUploadSuccess and stringUploadError applet parameters, here above.
  • You can put line breaks in the error message. The message must be in one line in the HTTP response. To display a line break to the user, just put the two characters \n in the http response (would be a "\\n" in java or PHP).
  • targetPictureFormat Empty String
    PictureUploadPolicy
    This parameter can contain a list to convert image formats

    Example 1:"png,bmp:jpg;gif:png;"

    • both png and bmp files will be converted to jpg,
    • gif files will be converted to png
    Example 2:"jpeg,jpg:png;"
    • both jpeg and jpg files will be converted to png,

    the value is expected to be a semi-colon separated list of relations from source-format(s) to a target format.
    format: {SOURCEFORMAT{,SOURCEFORMAT*}:TARGETFORMAT;}*
    • formats can contain any picture writer known by the JVM. For instance: jpeg, png, gif. All standard formats should be available. More information can be found on the java.sun.com web site.
    • SOURCEFORMAT: the source format that should be converted to the TARGETFORMAT
      e.g. png, jpg, jpeg, ..
    • TARGETFORMAT: the target format that all given SOURCEFORMAT should be converted to
      e.g. png, jpg, jpeg, ..
    • all format strings are case insensitive, so all following strings are the same:
      • "jpeg,jpg:png;"
      • "JPEG,JPG:PNG;"
      • "jPeG,JpG:pNg;"
    notes:
    • animated gifs will not be converted
    • jpg and jpeg are distinct types.
    • gifs can only be converted if the user has installed JRE >= 1.6
    • the trailing semi-colon is optional
    • when a file needs to be transformed, the content type will reflect the new picture format. the file extension will be changed dependant on the parameter keepOriginalFileExtensionForConvertedImages
      • example1:
        • targetPictureFormat="bmp:png;"
        • keepOriginalFileExtensionForConvertedImages=false (default)
        When you upload: C:\myBitmap.bmp, the filename will be changed to C:\myBitmap.png and transferred to the server, and the content-type will be changed to "image/png"
      • example2:
        • targetPictureFormat="bmp:png;"
        • keepOriginalFileExtensionForConvertedImages=true
        When you upload: C:\myBitmap.bmp, the filename will NOT be changed and transferred to the server, but the content-type will be changed to "image/png"
    see ImageFileConversionInfo
    see keepOriginalFileExtensionForConvertedImages
    uploadPolicy DefaultUploadPolicy

    see UploadPolicyFactory
    This parameter contains the class name for the UploadPolicy that should be used. If it is not set, or if its value is unknown from UploadPolicyFactory.getUploadPolicy(JUploadContext) , the DefaultUploadPolicy is used.
    urlToSendErrorTo null

    DefaultUploadPolicy
    If this url is given, and an upload error occurs, the applet posts all debug output to this address. It's up to this URL to handle this message. It is possible to just store the file, or to log the error in a database, or to send a mail (like the mail.php script given with the coppermine pack).
    Notes:
  • Only http and https URL schemes are supported.
  • The error information is sent in a POST request sent to the given URL. These post parameters are used: description (a quick description of the error), javaError (the java output for the error, or null if no java error were caught) and debugOutput (the full debug generated by the applet).
  • HTML call example

    Below, an example of how to put the applet into a PHP page is shown:

                                         <applet name="JUpload" code="wjhk.jupload2.JUploadApplet"
                                           archive="plugins/jupload/wjhk.jupload.jar"
                                           <!-- Applet display size, on the navigator page -->
                                           width="500" height="700"
                                           <!-- The applet uses some javascript functions, so we must allow that : -->
                                           mayscript>
                                           <!-- No parameter is mandatory. We don't precise the UploadPolicy, so
                                                DefaultUploadPolicy is used. The applet behaves like the original
                                                JUpload. (jupload v1) -->
                                           <param name="postURL" value="http://some.host.com/youruploadpage.php">
                                           Java 1.5 or higher plugin required.
                                         </applet>
     

    Version:
    $Revision: 963 $
    Author:
    etienne_sf
    See Also:
    DefaultUploadPolicy

    Field Summary
    static String DEFAULT_AFTER_UPLOAD_TARGET
              Default value for parameter "afterUploadTarget".
    static String DEFAULT_AFTER_UPLOAD_URL
              Default value for parameter "afterUploadURL"
    static int DEFAULT_ALBUM_ID
              Default value for parameter "albumId".
    static boolean DEFAULT_ALLOW_HTTP_PERSISTENT
              Default value for parameter "allowHttpPersisten".
    static String DEFAULT_ALLOWED_FILE_EXTENSIONS
              Default value for parameter "allowedFileExtensions".
    static String DEFAULT_BROWSING_DIRECTORY
              Default value for the browsing window first: no specific directory.
    static String DEFAULT_DATE_FORMAT
              Default value for date format when changing date/time variable to String.
    static int DEFAULT_DEBUG_LEVEL
              Default value for parameter "debugLevel".
    static int DEFAULT_FILE_CHOOSER_ICON_FROM_FILE_CONTENT
              Default value for applet parameter "fileChooserIconFromFileContent".
    static int DEFAULT_FILE_CHOOSER_ICON_SIZE
              Default value for applet parameter "fileChooserIconSize".
    static boolean DEFAULT_FILE_CHOOSER_IMAGE_PREVIEW
              Default value for applet parameter "fileChooserImagePreview".
    static String DEFAULT_FILENAME_ENCODING
              Default value for parameter "filenameEncoding".
    static String DEFAULT_FORMDATA
              Default value for parameter "formdata"
    static boolean DEFAULT_FTP_CREATE_DIRECTORY_STRUCTURE
              Default value for applet parameter "ftpCreateDirectoryStructure".
    static boolean DEFAULT_FTP_TRANSFERT_BINARY
              FTP: binary or ascii mode
    static boolean DEFAULT_FTP_TRANSFERT_PASSIVE
              FTP: passive or active mode
    static boolean DEFAULT_HIGH_QUALITY_PREVIEW
              Default value for parameter "highQualityPreview".
    static String DEFAULT_HTTP_UPLOAD_PARAMETER_NAME
              Default value for parameter "httpUploadParameterName".
    static String DEFAULT_HTTP_UPLOAD_PARAMETER_TYPE
              Default value for parameter "httpUploadParameterName".
    static boolean DEFAULT_KEEP_ORIG_EXTENSION
              default value for parameter "keepOriginalFileExtensionForConvertedImages"
    static String DEFAULT_LANG
              Default value for parameter "lang".
    static String DEFAULT_LOOK_AND_FEEL
              Default value for parameter "lookAndFeel".
    static long DEFAULT_MAX_CHUNK_SIZE
              Default value for parameter "maxChunkSize".
    static long DEFAULT_MAX_FILE_SIZE
              Default value for parameter "maxFileSize".
    static int DEFAULT_MAX_HEIGHT
              Default value for parameter "maxPicHeight".
    static int DEFAULT_MAX_WIDTH
              Default value for parameter "maxPicWidth".
    static int DEFAULT_NB_FILES_PER_REQUEST
              Default value for parameter "maxPicHeight".
    static float DEFAULT_PICTURE_COMPRESSION_QUALITY
              Default value for parameter "pictureCompressionQuality".
    static boolean DEFAULT_PICTURE_TRANSMIT_METADATA
              Default value for parameter "pictureCompressionQuality".
    static String DEFAULT_POST_URL
              Default value for parameter "postURL".
    static boolean DEFAULT_READ_COOKIE_FROM_NAVIGATOR
              Default value for parameter "readCookieFromNavigator".
    static boolean DEFAULT_READ_USER_AGENT_FROM_NAVIGATOR
              Default value for parameter "readUserAgentFromNavigator".
    static int DEFAULT_REAL_MAX_HEIGHT
              Default value for parameter "realMaxPicHeight".
    static int DEFAULT_REAL_MAX_WIDTH
              Default value for parameter "realMaxPicWidth".
    static String DEFAULT_SERVER_PROTOCOL
              Default value for parameter "serverProtocol".
    static String DEFAULT_SHOW_LOGWINDOW
              Default value for parameter "showLogWindow".
    static boolean DEFAULT_SHOW_STATUSBAR
              Default value for parameter "showStatusBar".
    static String DEFAULT_SPECIFIC_HEADERS
              Default value for parameter "sslVerifyCert"
    static String DEFAULT_SSL_VERIFY_CERT
              Default value for parameter "sslVerifyCert"
    static boolean DEFAULT_STORE_BUFFERED_IMAGE
              Default value for parameter "storeBufferedImage".
    static String DEFAULT_STRING_UPLOAD_ERROR
              Default value for parameter "stringUploadError".
    static String DEFAULT_STRING_UPLOAD_SUCCESS
              Default value for parameter "stringUploadSuccess".
    static String DEFAULT_STRING_UPLOAD_WARNING
              Default value for parameter "stringUploadWarning".
    static String DEFAULT_TARGET_PICTURE_FORMAT
              Default value for parameter "targetPictureFormat".
    static String DEFAULT_UPLOAD_POLICY
              Default value for parameter "uploadPolicy".
    static String DEFAULT_URL_TO_SEND_ERROR_TO
              Default value for parameter "urlToSendErrorTo".
    static String HTTPUPLOADPARAMETERTYPE_ARRAY
              Indicates that, in the HTTP upload request, the parameter that containts the uploaded files is an Iteration.
    static String HTTPUPLOADPARAMETERTYPE_ITERATION
              Indicates that, in the HTTP upload request, the parameter that containts the uploaded files is an Iteration.
    static String HTTPUPLOADPARAMETERTYPE_ONE_FILE
              Indicates that, in the HTTP upload request, there will be only one file.
    static String PROP_AFTER_UPLOAD_TARGET
              Parameter/Property name for specifying URL of the upload post request.
    static String PROP_AFTER_UPLOAD_URL
              Parameter/Property name for URL to be loaded after an successful upload.
    static String PROP_ALBUM_ID
              Parameter/Property name for specifying the album id
    static String PROP_ALLOW_HTTP_PERSISTENT
              Parameter/Property name for allowing persistent HTTP connections.
    static String PROP_ALLOWED_FILE_EXTENSIONS
              Parameter/Property name for specifying the allowed file extensions
    static String PROP_BROWSING_DIRECTORY
              Indicates the directory, from which the applet should open the browsing window (file chooser) first.
    static String PROP_DEBUG_LEVEL
              Parameter/Property name for specifying the debug level
    static String PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT
              This parameter allows to control whether the file icons in the file chooser are calculated from the file content.
    static String PROP_FILE_CHOOSER_ICON_SIZE
              This parameter allows to control the size of icons, in pixels, in the file chooser.
    static String PROP_FILE_CHOOSER_IMAGE_PREVIEW
              Allows control on the preview on the file chooser.
    static String PROP_FILENAME_ENCODING
              Parameter/Property name for specifying the encoding of file names.
    static String PROP_FORMDATA
              Parameter/Property name for specifying additional form data.
    static String PROP_FTP_CREATE_DIRECTORY_STRUCTURE
              Parameter/Property name to specify, when in FTP mode, if subfolders must be created, or if all files must be uploaded on the root of postURL.
    static String PROP_FTP_TRANSFERT_BINARY
              FTP: binary or ascii mode
    static String PROP_FTP_TRANSFERT_PASSIVE
              FTP: passive or active mode
    static String PROP_HIGH_QUALITY_PREVIEW
              Parameter/Property name for specifying high quality previews.
    static String PROP_HTTP_UPLOAD_PARAMETER_NAME
              Parameter/Property name for specifying high quality previews.
    static String PROP_HTTP_UPLOAD_PARAMETER_TYPE
              Parameter/Property name for specifying high quality previews.
    static String PROP_KEEP_ORIG_EXTENSION
              Parameter/Property name for specifying if the original file extension should be changed if an image is converted to another format
    static String PROP_LANG
              Parameter/Property name for specifying the UI language
    static String PROP_LOOK_AND_FEEL
              Parameter/Property name for specifying a PLAF class to load.
    static String PROP_MAX_CHUNK_SIZE
              Parameter/Property name for specifying the maximum size of a chunk of uploaded data.
    static String PROP_MAX_FILE_SIZE
              Parameter/Property name for specifying the maximum size of a single file.
    static String PROP_MAX_HEIGHT
              Parameter/Property name for specifying the maximum height of a picture.
    static String PROP_MAX_WIDTH
              Parameter/Property name for specifying the maximum width of a picture.
    static String PROP_NB_FILES_PER_REQUEST
              Parameter/Property name for specifying the maximum number of file to be uploaded in a single request.
    static String PROP_PICTURE_COMPRESSION_QUALITY
              Parameter/Property name for specifying compression of the written picture file, if any.
    static String PROP_PICTURE_TRANSMIT_METADATA
              Parameter/Property name for specifying whether picture metadata (EXIF coming from the camera for instance.
    static String PROP_POST_URL
              Parameter/Property name for specifying URL of the upload post request.
    static String PROP_READ_COOKIE_FROM_NAVIGATOR
              Read cookies from javascript command: document.cookie (or not)
    static String PROP_READ_USER_AGENT_FROM_NAVIGATOR
              Read userAgent from javascript command: document.userAgent (or not)
    static String PROP_REAL_MAX_HEIGHT
              Parameter/Property name for specifying the real (server-side-desired) picture height.
    static String PROP_REAL_MAX_WIDTH
              Parameter/Property name for specifying the real (server-side-desired) picture width.
    static String PROP_SERVER_PROTOCOL
              Parameter/Property name for specifying the server protocol version.
    static String PROP_SHOW_LOGWINDOW
              Parameter/Property name for specifying if the log window should be visible.
    static String PROP_SHOW_STATUSBAR
              Parameter/Property name for specifying if the status bar should be visible.
    static String PROP_SPECIFIC_HEADERS
              Parameter/Property name for specifying a list of specific headers, that will be added to all HTTP request to the server.
    static String PROP_SSL_VERIFY_CERT
              Parameter/Property name for specifying how certificates are handled when uploading via SSL.
    static String PROP_STORE_BUFFERED_IMAGE
              Parameter/Property name for specifying if images should be cached in memory.
    static String PROP_STRING_UPLOAD_ERROR
              Parameter/Property name for specifying if the pattern that indicates an error in the server's response-body.
    static String PROP_STRING_UPLOAD_SUCCESS
              Parameter/Property name for specifying if the pattern that indicates success in the server's response-body.
    static String PROP_STRING_UPLOAD_WARNING
              Parameter/Property name for specifying if the pattern that indicates a warning in the server's response-body.
    static String PROP_TARGET_PICTURE_FORMAT
              Parameter/Property name for specifying the target picture format conversions
    static String PROP_UPLOAD_POLICY
              Parameter/Property name for specifying the upload policy class.
    static String PROP_URL_TO_SEND_ERROR_TO
              Parameter/Property name for specifying the URL for delivering error reports.
    static String SHOWLOGWINDOW_FALSE
              Indicates that the log window is always hidden.
    static String SHOWLOGWINDOW_ONERROR
              Indicates that the log window is hidden, and will become visible only when an error occurs.
    static String SHOWLOGWINDOW_TRUE
              Indicates that the log window is always visible.
     
    Method Summary
     void addComponentsToJUploadPanel(JUploadPanel jUploadPanel)
              This methods allow the upload policy to override the default disposition of the components on the applet.
     void addHeader(String header)
              Add an header to the list of headers that will be added to each HTTP upload request.
     void afterFileDropped(DropTargetDropEvent dropEvent)
              Reaction by the upload policy, once the management of the dropped file(s) is finished, that is: after all the dropped files have been successfully added to the file list.
     void afterUpload(Exception e, String serverOutput)
              This method is called after an upload, whether it is successful or not.
     void alert(String key)
              Displays a MessageBox with a unique 'Ok' button, by calling the JOptionPane.showMessageDialog(java.awt.Component, Object) method.
     void alertStr(String str)
              Displays a MessageBox with a unique 'Ok' button, by calling the JOptionPane.showMessageDialog(java.awt.Component, Object) method.
     boolean beforeUpload()
              Execute any action, that must be done before upload.
     boolean checkUploadSuccess(int status, String msg, String body)
              This method returns true, if upload is a success.
     int confirmDialogStr(String str, int optionTypes)
              Displays a MessageBox with a unique 'Ok' button, by calling the JOptionPane.showConfirmDialog(java.awt.Component, Object, String, int) method.
     JUploadFileChooser createFileChooser()
              The creation of the file chooser is controled by the upload policy, to allow fine control of the way to select files.
     FileData createFileData(File file, File root)
              This methods creates a new FileData instance (or one of its inherited classes), and return it to the caller.
     JPanel createProgressPanel(JProgressBar preparationProgressBar, JProgressBar uploadProgressBar, JButton uploadButton, JButton stopButton, JPanel mainPanel)
              This method is called to create the progress panel.
     JPanel createStatusBar(JLabel statusContent, JPanel mainPanel)
              This method is used to create a new status bar.
     JPanel createTopPanel(JButton browse, JButton remove, JButton removeAll, JUploadPanel mainPanel)
              This method allows the upolad policy to override the content of the applet part that is above the file list, called here the 'top panel'.
     void displayDebug(String debug, int minDebugLevel)
              log a debug message.
     void displayErr(Exception e)
              log an error message, based on an exception.
     void displayErr(String err)
              log an error message.
     void displayErr(String err, Exception e)
              log an error message.
     int displayErr(String err, Exception e, int optionType)
              log an error message, based on an exception.
     void displayInfo(String info)
              log an info message.
     void displayParameterStatus()
              This method displays the applet parameter list, according to the current debugLevel.
     void displayWarn(String warn)
              log a warning message.
     boolean fileFilterAccept(File file)
              This methods is called by the JUploadFileFilter.accept(File).
     String fileFilterGetDescription()
              Return a description for the FileFilter, according to the current upload policy.
     Icon fileViewGetIcon(File file)
              Response for the JUploadFileView.getIcon(File).
     String getAfterUploadTarget()
              Return the target, specified as applet parameter "afterUploadTarget"
     String getAfterUploadURL()
              Retrieves the current value for the afterUploadURL applet parameter.
     String getAllowedFileExtensions()
              Retrieves the current value for allowedFileExtensions *
     boolean getAllowHttpPersistent()
              Retrieves the current value for allowHttpPersistent
     wjhk.jupload2.context.JUploadContext getContext()
              A useful function, that has nothing to do with an upload policy.
     File getCurrentBrowsingDirectory()
              Returns the current browsing directory, that is: the directory that will be current the next time the file chooser is opened.
     String getDateFormat()
              Returns the currently choosen format for date.
     int getDebugLevel()
              This method returns the current debug level.
     int getFileChooserIconFromFileContent()
              Getter for the fileChooserIconFromFileContent applet parameter.
     int getFileChooserIconSize()
              Getter for the fileChooserIconSize applet parameter.
     String getFilenameEncoding()
              Returns the encoding that should be used for the filename.
     String getFormdata()
              Retrieve the applet's "formdata" parameter.
     boolean getFtpCreateDirectoryStructure()
              Returns the current value for the ftpCreateDirectoryStructure applet parameter.
     boolean getFtpTransfertBinary()
              Returns the current value for the ftpTransfertBinary applet parameter.
     boolean getFtpTransfertPassive()
              Returns the current value for the ftpTransfertPassive applet parameter.
     String getHttpUploadParameterName()
              Retrieve the applet's "httpUploadParameterName" parameter.
     String getHttpUploadParameterType()
              Retrieve the applet's "httpUploadParameterType" parameter.
     JUploadException getLastException()
              Indicates that an error occurs.
     String getLastResponseBody()
              Retrieve the body of the last server response.
     String getLastResponseMessage()
              Retrieve the status/error message of the last server response.
     String getLocalizedString(String key, Object... args)
              Retrieve a lang string, based on the file cointained in the wjhk.jupload2.lang package.
     long getMaxChunkSize()
              Returns the value of the applet parameter maxChunkSize (see above for a description of all applet parameters)
     long getMaxFileSize()
              Returns the value of the applet parameter maxFileSize (see above for a description of all applet parameters)
     int getNbFilesPerRequest()
              This function returns the number of files should be uploaded during one access to the server.
     String getPostURL()
              Get the target URL for upload.
     boolean getReadCookieFromNavigator()
              Return the current value of readCookieFromNavigator
     boolean getReadUserAgentFromNavigator()
              Return the current value of readUserAgentFromNavigator
     String getServerProtocol()
              HTTP protocol that should be used to send the HTTP request.
     String getShowLogWindow()
              Indicate whether the log window should be shown.
     String getSpecificHeaders()
              Returns the list of specific headers, that will be added to all HTTP request to the server.
     int getSslVerifyCert()
              Retrieves SSL verification mode.
     String getStringUploadError()
              Retrieve the regular expression that will be tested against each line of the server answer.
     String getStringUploadSuccess()
              Get the regular expression that will be tested against each line of the server answer.
     String getStringUploadWarning()
              Retrieve the regular expression that will be tested against each line of the server answer.
     String getUploadFilename(FileData fileData, int index)
              Get the original name of the file on the disk.
     String getUploadName(FileData fileData, int index)
              Get an upload filename, that is to be send in the HTTP upload request.
     String getUrlToSendErrorTo()
              Returns the current URL where error log must be posted.
     wjhk.jupload2.upload.helper.ByteArrayEncoder onAppendHeader(wjhk.jupload2.upload.helper.ByteArrayEncoder sb)
              Append specific headers for this upload (session cookies, for instance).
     void onFileDoubleClicked(FileData fileData)
              Reaction when the user double click on a file, in the file list.
     void onFileSelected(FileData fileData)
              This method is called each time a file is selected in the panel files.
     void sendDebugInformation(String reason, Exception exception)
              This method allows the applet to post debug information to the website (see getUrlToSendErrorTo()).
     void setCurrentBrowsingDirectory(File currentBrowsingDirectoryParam)
              Deprecated.  
     void setCurrentBrowsingDirectory(String currentBrowsingDirectoryParam)
              Set the current directory.
     Cursor setCursor(Cursor cursor)
              Changes the current mouse cursor.
     void setDebugLevel(int debugLevel)
              This method indicate whether or not the debug messages must be displayed.
     void setLang(String lang)
              This method sets the current language to take into account.
     void setPostURL(String postURL)
              The URL can change during the life of our policy ...
     void setProperty(String prop, String value)
              This allow runtime modifications of properties.
     void setServerProtocol(String serverProtocol)
               
     void setShowLogWindow(String showLogWindow)
               
     void setUrlToSendErrorTo(String urlToSendErrorTo)
               
     Cursor setWaitCursor()
              This method changes the current mouse cursor to the wait one.
     

    Field Detail

    PROP_AFTER_UPLOAD_URL

    static final String PROP_AFTER_UPLOAD_URL
    Parameter/Property name for URL to be loaded after an successful upload.

    See Also:
    Constant Field Values

    PROP_ALLOW_HTTP_PERSISTENT

    static final String PROP_ALLOW_HTTP_PERSISTENT
    Parameter/Property name for allowing persistent HTTP connections.

    See Also:
    Constant Field Values

    PROP_ALLOWED_FILE_EXTENSIONS

    static final String PROP_ALLOWED_FILE_EXTENSIONS
    Parameter/Property name for specifying the allowed file extensions

    See Also:
    Constant Field Values

    PROP_ALBUM_ID

    static final String PROP_ALBUM_ID
    Parameter/Property name for specifying the album id

    See Also:
    Constant Field Values

    PROP_BROWSING_DIRECTORY

    static final String PROP_BROWSING_DIRECTORY
    Indicates the directory, from which the applet should open the browsing window (file chooser) first.

    See Also:
    Constant Field Values

    PROP_STORE_BUFFERED_IMAGE

    static final String PROP_STORE_BUFFERED_IMAGE
    Parameter/Property name for specifying if images should be cached in memory. Be careful: if set to true, you'll probably have memory problems while in a navigator.

    See Also:
    Constant Field Values

    PROP_DEBUG_LEVEL

    static final String PROP_DEBUG_LEVEL
    Parameter/Property name for specifying the debug level

    See Also:
    Constant Field Values

    PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT

    static final String PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT
    This parameter allows to control whether the file icons in the file chooser are calculated from the file content. This is currently only available for pictures.
    If activated, the file chooser will open each pictures, and calculate the icon by resizing the picture. This is done in by using thread of minimam priority, to minimize performances impact on the navigator. Available values are:
  • -1: disabled. The default system are used.
  • 0 (default): available only in picture mode. That is: the current upload policy is an instance of or a class inheriting from PictureUploadPolicy
  • 1: available for all upload policies.
  • See Also:
    Constant Field Values

    PROP_FILE_CHOOSER_ICON_SIZE

    static final String PROP_FILE_CHOOSER_ICON_SIZE
    This parameter allows to control the size of icons, in pixels, in the file chooser. Used only when fileChooserIconFromFileContent is activated.

    See Also:
    Constant Field Values

    PROP_FILE_CHOOSER_IMAGE_PREVIEW

    static final String PROP_FILE_CHOOSER_IMAGE_PREVIEW
    Allows control on the preview on the file chooser. Only for PictureUploadPolicy and its inheritants.

    See Also:
    Constant Field Values

    PROP_FILENAME_ENCODING

    static final String PROP_FILENAME_ENCODING
    Parameter/Property name for specifying the encoding of file names.

    See Also:
    Constant Field Values

    PROP_FORMDATA

    static final String PROP_FORMDATA
    Parameter/Property name for specifying additional form data.

    See Also:
    Constant Field Values

    PROP_FTP_CREATE_DIRECTORY_STRUCTURE

    static final String PROP_FTP_CREATE_DIRECTORY_STRUCTURE
    Parameter/Property name to specify, when in FTP mode, if subfolders must be created, or if all files must be uploaded on the root of postURL.

    See Also:
    Constant Field Values

    PROP_FTP_TRANSFERT_BINARY

    static final String PROP_FTP_TRANSFERT_BINARY
    FTP: binary or ascii mode

    See Also:
    Constant Field Values

    PROP_FTP_TRANSFERT_PASSIVE

    static final String PROP_FTP_TRANSFERT_PASSIVE
    FTP: passive or active mode

    See Also:
    Constant Field Values

    PROP_HIGH_QUALITY_PREVIEW

    static final String PROP_HIGH_QUALITY_PREVIEW
    Parameter/Property name for specifying high quality previews.

    See Also:
    Constant Field Values

    PROP_HTTP_UPLOAD_PARAMETER_NAME

    static final String PROP_HTTP_UPLOAD_PARAMETER_NAME
    Parameter/Property name for specifying high quality previews.

    See Also:
    Constant Field Values

    PROP_HTTP_UPLOAD_PARAMETER_TYPE

    static final String PROP_HTTP_UPLOAD_PARAMETER_TYPE
    Parameter/Property name for specifying high quality previews.

    See Also:
    Constant Field Values

    PROP_LANG

    static final String PROP_LANG
    Parameter/Property name for specifying the UI language

    See Also:
    Constant Field Values

    PROP_SPECIFIC_HEADERS

    static final String PROP_SPECIFIC_HEADERS
    Parameter/Property name for specifying a list of specific headers, that will be added to all HTTP request to the server. The parameter can be used for Basic Authentication, by adding this header: Authorization: Basic [Bae64 encoding of the string "user:password"]

    See Also:
    Constant Field Values

    PROP_LOOK_AND_FEEL

    static final String PROP_LOOK_AND_FEEL
    Parameter/Property name for specifying a PLAF class to load.

    See Also:
    Constant Field Values

    PROP_MAX_CHUNK_SIZE

    static final String PROP_MAX_CHUNK_SIZE
    Parameter/Property name for specifying the maximum size of a chunk of uploaded data.

    See Also:
    Constant Field Values

    PROP_MAX_FILE_SIZE

    static final String PROP_MAX_FILE_SIZE
    Parameter/Property name for specifying the maximum size of a single file.

    See Also:
    Constant Field Values

    PROP_MAX_HEIGHT

    static final String PROP_MAX_HEIGHT
    Parameter/Property name for specifying the maximum height of a picture.

    See Also:
    Constant Field Values

    PROP_MAX_WIDTH

    static final String PROP_MAX_WIDTH
    Parameter/Property name for specifying the maximum width of a picture.

    See Also:
    Constant Field Values

    PROP_NB_FILES_PER_REQUEST

    static final String PROP_NB_FILES_PER_REQUEST
    Parameter/Property name for specifying the maximum number of file to be uploaded in a single request.

    See Also:
    Constant Field Values

    PROP_PICTURE_COMPRESSION_QUALITY

    static final String PROP_PICTURE_COMPRESSION_QUALITY
    Parameter/Property name for specifying compression of the written picture file, if any.

    See Also:
    Constant Field Values

    PROP_PICTURE_TRANSMIT_METADATA

    static final String PROP_PICTURE_TRANSMIT_METADATA
    Parameter/Property name for specifying whether picture metadata (EXIF coming from the camera for instance.

    See Also:
    Constant Field Values

    PROP_POST_URL

    static final String PROP_POST_URL
    Parameter/Property name for specifying URL of the upload post request.

    See Also:
    Constant Field Values

    PROP_AFTER_UPLOAD_TARGET

    static final String PROP_AFTER_UPLOAD_TARGET
    Parameter/Property name for specifying URL of the upload post request.

    See Also:
    Constant Field Values

    PROP_READ_COOKIE_FROM_NAVIGATOR

    static final String PROP_READ_COOKIE_FROM_NAVIGATOR
    Read cookies from javascript command: document.cookie (or not)

    See Also:
    Constant Field Values

    PROP_READ_USER_AGENT_FROM_NAVIGATOR

    static final String PROP_READ_USER_AGENT_FROM_NAVIGATOR
    Read userAgent from javascript command: document.userAgent (or not)

    See Also:
    Constant Field Values

    PROP_REAL_MAX_HEIGHT

    static final String PROP_REAL_MAX_HEIGHT
    Parameter/Property name for specifying the real (server-side-desired) picture height.

    See Also:
    Constant Field Values

    PROP_REAL_MAX_WIDTH

    static final String PROP_REAL_MAX_WIDTH
    Parameter/Property name for specifying the real (server-side-desired) picture width.

    See Also:
    Constant Field Values

    PROP_SERVER_PROTOCOL

    static final String PROP_SERVER_PROTOCOL
    Parameter/Property name for specifying the server protocol version.

    See Also:
    Constant Field Values

    PROP_SHOW_LOGWINDOW

    static final String PROP_SHOW_LOGWINDOW
    Parameter/Property name for specifying if the log window should be visible.

    See Also:
    Constant Field Values

    PROP_SHOW_STATUSBAR

    static final String PROP_SHOW_STATUSBAR
    Parameter/Property name for specifying if the status bar should be visible.

    See Also:
    Constant Field Values

    PROP_SSL_VERIFY_CERT

    static final String PROP_SSL_VERIFY_CERT
    Parameter/Property name for specifying how certificates are handled when uploading via SSL.

    See Also:
    Constant Field Values

    PROP_STRING_UPLOAD_ERROR

    static final String PROP_STRING_UPLOAD_ERROR
    Parameter/Property name for specifying if the pattern that indicates an error in the server's response-body.

    See Also:
    Constant Field Values

    PROP_STRING_UPLOAD_SUCCESS

    static final String PROP_STRING_UPLOAD_SUCCESS
    Parameter/Property name for specifying if the pattern that indicates success in the server's response-body.

    See Also:
    Constant Field Values

    PROP_STRING_UPLOAD_WARNING

    static final String PROP_STRING_UPLOAD_WARNING
    Parameter/Property name for specifying if the pattern that indicates a warning in the server's response-body.

    See Also:
    Constant Field Values

    PROP_TARGET_PICTURE_FORMAT

    static final String PROP_TARGET_PICTURE_FORMAT
    Parameter/Property name for specifying the target picture format conversions

    See Also:
    Constant Field Values

    PROP_KEEP_ORIG_EXTENSION

    static final String PROP_KEEP_ORIG_EXTENSION
    Parameter/Property name for specifying if the original file extension should be changed if an image is converted to another format

    See Also:
    Constant Field Values

    PROP_UPLOAD_POLICY

    static final String PROP_UPLOAD_POLICY
    Parameter/Property name for specifying the upload policy class.

    See Also:
    Constant Field Values

    PROP_URL_TO_SEND_ERROR_TO

    static final String PROP_URL_TO_SEND_ERROR_TO
    Parameter/Property name for specifying the URL for delivering error reports.

    See Also:
    Constant Field Values

    HTTPUPLOADPARAMETERTYPE_ARRAY

    static final String HTTPUPLOADPARAMETERTYPE_ARRAY
    Indicates that, in the HTTP upload request, the parameter that containts the uploaded files is an Iteration. For instance: from File0 to FileN (for N+1 files).

    See Also:
    Constant Field Values

    HTTPUPLOADPARAMETERTYPE_ITERATION

    static final String HTTPUPLOADPARAMETERTYPE_ITERATION
    Indicates that, in the HTTP upload request, the parameter that containts the uploaded files is an Iteration. For instance: from File0 to FileN (for N+1 files).

    See Also:
    Constant Field Values

    HTTPUPLOADPARAMETERTYPE_ONE_FILE

    static final String HTTPUPLOADPARAMETERTYPE_ONE_FILE
    Indicates that, in the HTTP upload request, there will be only one file. This value is only valid when nbFilesPerRequest is 1. The parameters in the HTTP upload request are let untransformed. For instance, if httpUploadParameterName is the default value (File), the file content will be loaded under the HTTP parameter 'File'.

    See Also:
    Constant Field Values

    SHOWLOGWINDOW_TRUE

    static final String SHOWLOGWINDOW_TRUE
    Indicates that the log window is always visible.

    See Also:
    Constant Field Values

    SHOWLOGWINDOW_FALSE

    static final String SHOWLOGWINDOW_FALSE
    Indicates that the log window is always hidden.

    See Also:
    Constant Field Values

    SHOWLOGWINDOW_ONERROR

    static final String SHOWLOGWINDOW_ONERROR
    Indicates that the log window is hidden, and will become visible only when an error occurs.

    See Also:
    Constant Field Values

    DEFAULT_AFTER_UPLOAD_TARGET

    static final String DEFAULT_AFTER_UPLOAD_TARGET
    Default value for parameter "afterUploadTarget".


    DEFAULT_AFTER_UPLOAD_URL

    static final String DEFAULT_AFTER_UPLOAD_URL
    Default value for parameter "afterUploadURL"


    DEFAULT_ALLOW_HTTP_PERSISTENT

    static final boolean DEFAULT_ALLOW_HTTP_PERSISTENT
    Default value for parameter "allowHttpPersisten".

    See Also:
    Constant Field Values

    DEFAULT_ALLOWED_FILE_EXTENSIONS

    static final String DEFAULT_ALLOWED_FILE_EXTENSIONS
    Default value for parameter "allowedFileExtensions".


    DEFAULT_ALBUM_ID

    static final int DEFAULT_ALBUM_ID
    Default value for parameter "albumId".

    See Also:
    Constant Field Values

    DEFAULT_STORE_BUFFERED_IMAGE

    static final boolean DEFAULT_STORE_BUFFERED_IMAGE
    Default value for parameter "storeBufferedImage". Be careful: if set to true, you'll probably have memory problems while in a navigator.

    See Also:
    Constant Field Values

    DEFAULT_BROWSING_DIRECTORY

    static final String DEFAULT_BROWSING_DIRECTORY
    Default value for the browsing window first: no specific directory.


    DEFAULT_DATE_FORMAT

    static final String DEFAULT_DATE_FORMAT
    Default value for date format when changing date/time variable to String.

    See Also:
    Constant Field Values

    DEFAULT_DEBUG_LEVEL

    static final int DEFAULT_DEBUG_LEVEL
    Default value for parameter "debugLevel".

    See Also:
    Constant Field Values

    DEFAULT_FILE_CHOOSER_ICON_FROM_FILE_CONTENT

    static final int DEFAULT_FILE_CHOOSER_ICON_FROM_FILE_CONTENT
    Default value for applet parameter "fileChooserIconFromFileContent".

    See Also:
    PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT, Constant Field Values

    DEFAULT_FILE_CHOOSER_ICON_SIZE

    static final int DEFAULT_FILE_CHOOSER_ICON_SIZE
    Default value for applet parameter "fileChooserIconSize".

    See Also:
    PROP_FILE_CHOOSER_ICON_SIZE, Constant Field Values

    DEFAULT_FILE_CHOOSER_IMAGE_PREVIEW

    static final boolean DEFAULT_FILE_CHOOSER_IMAGE_PREVIEW
    Default value for applet parameter "fileChooserImagePreview".

    See Also:
    PROP_FILE_CHOOSER_IMAGE_PREVIEW, Constant Field Values

    DEFAULT_FTP_CREATE_DIRECTORY_STRUCTURE

    static final boolean DEFAULT_FTP_CREATE_DIRECTORY_STRUCTURE
    Default value for applet parameter "ftpCreateDirectoryStructure".

    See Also:
    PROP_FTP_CREATE_DIRECTORY_STRUCTURE, Constant Field Values

    DEFAULT_FTP_TRANSFERT_BINARY

    static final boolean DEFAULT_FTP_TRANSFERT_BINARY
    FTP: binary or ascii mode

    See Also:
    Constant Field Values

    DEFAULT_FTP_TRANSFERT_PASSIVE

    static final boolean DEFAULT_FTP_TRANSFERT_PASSIVE
    FTP: passive or active mode

    See Also:
    Constant Field Values

    DEFAULT_LANG

    static final String DEFAULT_LANG
    Default value for parameter "lang".


    DEFAULT_FILENAME_ENCODING

    static final String DEFAULT_FILENAME_ENCODING
    Default value for parameter "filenameEncoding". Note: the CoppermineUploadPolicy forces it to "UTF8".


    DEFAULT_HIGH_QUALITY_PREVIEW

    static final boolean DEFAULT_HIGH_QUALITY_PREVIEW
    Default value for parameter "highQualityPreview".

    See Also:
    Constant Field Values

    DEFAULT_HTTP_UPLOAD_PARAMETER_NAME

    static final String DEFAULT_HTTP_UPLOAD_PARAMETER_NAME
    Default value for parameter "httpUploadParameterName".

    See Also:
    Constant Field Values

    DEFAULT_HTTP_UPLOAD_PARAMETER_TYPE

    static final String DEFAULT_HTTP_UPLOAD_PARAMETER_TYPE
    Default value for parameter "httpUploadParameterName".

    See Also:
    Constant Field Values

    DEFAULT_LOOK_AND_FEEL

    static final String DEFAULT_LOOK_AND_FEEL
    Default value for parameter "lookAndFeel".

    See Also:
    Constant Field Values

    DEFAULT_MAX_CHUNK_SIZE

    static final long DEFAULT_MAX_CHUNK_SIZE
    Default value for parameter "maxChunkSize".

    See Also:
    Constant Field Values

    DEFAULT_MAX_FILE_SIZE

    static final long DEFAULT_MAX_FILE_SIZE
    Default value for parameter "maxFileSize". Take care of this parameter if chunk upload is activated! See comment above.

    See Also:
    Constant Field Values

    DEFAULT_MAX_WIDTH

    static final int DEFAULT_MAX_WIDTH
    Default value for parameter "maxPicWidth".

    See Also:
    Constant Field Values

    DEFAULT_MAX_HEIGHT

    static final int DEFAULT_MAX_HEIGHT
    Default value for parameter "maxPicHeight".

    See Also:
    Constant Field Values

    DEFAULT_NB_FILES_PER_REQUEST

    static final int DEFAULT_NB_FILES_PER_REQUEST
    Default value for parameter "maxPicHeight". Note: the CoppermineUploadPolicy forces it to 1.

    See Also:
    Constant Field Values

    DEFAULT_PICTURE_COMPRESSION_QUALITY

    static final float DEFAULT_PICTURE_COMPRESSION_QUALITY
    Default value for parameter "pictureCompressionQuality".

    See Also:
    Constant Field Values

    DEFAULT_PICTURE_TRANSMIT_METADATA

    static final boolean DEFAULT_PICTURE_TRANSMIT_METADATA
    Default value for parameter "pictureCompressionQuality".

    See Also:
    Constant Field Values

    DEFAULT_POST_URL

    static final String DEFAULT_POST_URL
    Default value for parameter "postURL".


    DEFAULT_READ_COOKIE_FROM_NAVIGATOR

    static final boolean DEFAULT_READ_COOKIE_FROM_NAVIGATOR
    Default value for parameter "readCookieFromNavigator".

    See Also:
    Constant Field Values

    DEFAULT_READ_USER_AGENT_FROM_NAVIGATOR

    static final boolean DEFAULT_READ_USER_AGENT_FROM_NAVIGATOR
    Default value for parameter "readUserAgentFromNavigator".

    See Also:
    Constant Field Values

    DEFAULT_REAL_MAX_WIDTH

    static final int DEFAULT_REAL_MAX_WIDTH
    Default value for parameter "realMaxPicWidth".

    See Also:
    Constant Field Values

    DEFAULT_REAL_MAX_HEIGHT

    static final int DEFAULT_REAL_MAX_HEIGHT
    Default value for parameter "realMaxPicHeight".

    See Also:
    Constant Field Values

    DEFAULT_SERVER_PROTOCOL

    static final String DEFAULT_SERVER_PROTOCOL
    Default value for parameter "serverProtocol".

    See Also:
    Constant Field Values

    DEFAULT_SHOW_LOGWINDOW

    static final String DEFAULT_SHOW_LOGWINDOW
    Default value for parameter "showLogWindow".

    See Also:
    Constant Field Values

    DEFAULT_SHOW_STATUSBAR

    static final boolean DEFAULT_SHOW_STATUSBAR
    Default value for parameter "showStatusBar".

    See Also:
    Constant Field Values

    DEFAULT_SPECIFIC_HEADERS

    static final String DEFAULT_SPECIFIC_HEADERS
    Default value for parameter "sslVerifyCert"


    DEFAULT_SSL_VERIFY_CERT

    static final String DEFAULT_SSL_VERIFY_CERT
    Default value for parameter "sslVerifyCert"

    See Also:
    Constant Field Values

    DEFAULT_STRING_UPLOAD_ERROR

    static final String DEFAULT_STRING_UPLOAD_ERROR
    Default value for parameter "stringUploadError".

    Since:
    2.9.2rc4
    See Also:
    Constant Field Values

    DEFAULT_STRING_UPLOAD_SUCCESS

    static final String DEFAULT_STRING_UPLOAD_SUCCESS
    Default value for parameter "stringUploadSuccess". Note: was ".* 200 OK$" before 2.9.0

    See Also:
    Constant Field Values

    DEFAULT_STRING_UPLOAD_WARNING

    static final String DEFAULT_STRING_UPLOAD_WARNING
    Default value for parameter "stringUploadWarning".

    See Also:
    Constant Field Values

    DEFAULT_TARGET_PICTURE_FORMAT

    static final String DEFAULT_TARGET_PICTURE_FORMAT
    Default value for parameter "targetPictureFormat".


    DEFAULT_KEEP_ORIG_EXTENSION

    static final boolean DEFAULT_KEEP_ORIG_EXTENSION
    default value for parameter "keepOriginalFileExtensionForConvertedImages"

    See Also:
    Constant Field Values

    DEFAULT_UPLOAD_POLICY

    static final String DEFAULT_UPLOAD_POLICY
    Default value for parameter "uploadPolicy".

    See Also:
    Constant Field Values

    DEFAULT_URL_TO_SEND_ERROR_TO

    static final String DEFAULT_URL_TO_SEND_ERROR_TO
    Default value for parameter "urlToSendErrorTo".


    DEFAULT_FORMDATA

    static final String DEFAULT_FORMDATA
    Default value for parameter "formdata"

    Since:
    2.9.2rc4
    Method Detail

    createTopPanel

    JPanel createTopPanel(JButton browse,
                          JButton remove,
                          JButton removeAll,
                          JUploadPanel mainPanel)
    This method allows the upolad policy to override the content of the applet part that is above the file list, called here the 'top panel'. That is: the part that contains the Browse, Remove and RemoveAll buttons. The default implementation is defined in DefaultUploadPolicy.createTopPanel(JButton, JButton, JButton, JUploadPanel) .
    You can see an example in the PictureUploadPolicy.createTopPanel(JButton, JButton, JButton, JUploadPanel) upload policy implementation.
    Note: This method is called by the DefaultUploadPolicy.addComponentsToJUploadPanel(JUploadPanel) method. If you create an upload policy that overrides the addComponentsToJUploadPanel method, it's up to you to call it.

    Parameters:
    browse - The default browse button.
    remove - The default removeSelected button.
    removeAll - The default removeAll button.
    mainPanel - The panel that contains all objects.
    Returns:
    the topPanel, that will be displayed on the top of the Applet.

    createProgressPanel

    JPanel createProgressPanel(JProgressBar preparationProgressBar,
                               JProgressBar uploadProgressBar,
                               JButton uploadButton,
                               JButton stopButton,
                               JPanel mainPanel)
    This method is called to create the progress panel. The default implementation is defined in DefaultUploadPolicy.createProgressPanel(JProgressBar, JProgressBar, JButton, JButton, JPanel) .

    Parameters:
    preparationProgressBar - The default preparation progress bar.
    uploadProgressBar - The default upload progress bar.
    uploadButton - The default upload button.
    stopButton - The default stop button.
    mainPanel - The panel that contains all objects.
    Returns:
    the topPanel, that will be displayed on the top of the Applet.

    createStatusBar

    JPanel createStatusBar(JLabel statusContent,
                           JPanel mainPanel)
    This method is used to create a new status bar. The default implementation is defined in DefaultUploadPolicy.createStatusBar(JLabel, JPanel) .

    Parameters:
    statusContent - The status bar content
    mainPanel - The panel that contains all objects.
    Returns:
    the topPanel, that will be displayed on the top of the Applet.

    addComponentsToJUploadPanel

    void addComponentsToJUploadPanel(JUploadPanel jUploadPanel)
    This methods allow the upload policy to override the default disposition of the components on the applet.

    Parameters:
    jUploadPanel - The main applet panel.
    See Also:
    createTopPanel(JButton, JButton, JButton, JUploadPanel)

    createFileData

    FileData createFileData(File file,
                            File root)
                            throws JUploadExceptionStopAddingFiles
    This methods creates a new FileData instance (or one of its inherited classes), and return it to the caller.

    Parameters:
    file - The file used to create the FileData instance. This method is called once for each file selected by the user, even if the user added several files in one 'shot'.
    root - An optional toplevel directory of a hierarchy (can be null).
    Returns:
    A FileData instance. The exact class depends on the currentUploadPolicy. Can be null, if the policy performs checks, and the given file is not Ok for these controls. See PictureUploadPolicy.createFileData(File,File) for an example. It's up to the upload policy to display a message to inform the user that this file won't be added to the file list.
    Throws:
    JUploadExceptionStopAddingFiles - The exception is not really an error. It allows an easy way to indicates that the applet should stop adding files when the user clicked on the 'Cancel' button.

    displayParameterStatus

    void displayParameterStatus()
    This method displays the applet parameter list, according to the current debugLevel. It is called by the setDebugLevel(int) method. It should be override by any subclasses, that should display its own parameters, then call super.displayParameterStatus().


    setProperty

    void setProperty(String prop,
                     String value)
                     throws JUploadException
    This allow runtime modifications of properties. With this method, you can change any applet parameter after the applet initilization, with JavaScript for instance. If the applet parameters given in prop is not managed by this method, a warning is displayed in the log window.

    Parameters:
    prop - The applet parameter name.
    value - The new value for this parameter. If the value is not valid (for instance aaa for a number), a warning is displayed in the log window, and the existing value is not changed.
    Throws:
    JUploadException
    JUploadExceptionStopAddingFiles - indicates that the applet should stop strying adding the current file selection. Useful for instance, when a user drop a directory, full of unallowed file: it's annoying for the user to click 'Ok' for each file in the alert box.

    getAfterUploadURL

    String getAfterUploadURL()
    Retrieves the current value for the afterUploadURL applet parameter.

    Returns:
    The current value for he afterUploadURL applet parameter.

    getAllowHttpPersistent

    boolean getAllowHttpPersistent()
    Retrieves the current value for allowHttpPersistent

    Returns:
    Current value for allowHttpPersistent

    getAllowedFileExtensions

    String getAllowedFileExtensions()
    Retrieves the current value for allowedFileExtensions *

    Returns:
    Current value for allowedFileExtensions

    getContext

    wjhk.jupload2.context.JUploadContext getContext()
    A useful function, that has nothing to do with an upload policy. But it is useful to have it here, as the uploadPolicy is known everywhere in the applet.

    Returns:
    Reference to the current JUpload context.

    setCurrentBrowsingDirectory

    void setCurrentBrowsingDirectory(File currentBrowsingDirectoryParam)
    Deprecated. 

    Set the current directory.

    Parameters:
    currentBrowsingDirectoryParam - The directory that will be the current one, the next time the file chooser is opened.
    See Also:
    getCurrentBrowsingDirectory()

    setCurrentBrowsingDirectory

    void setCurrentBrowsingDirectory(String currentBrowsingDirectoryParam)
    Set the current directory.

    Parameters:
    currentBrowsingDirectoryParam - The directory that will be the current one, the next time the file chooser is opened. This directory may begin with ~/ or ~\
    See Also:
    getCurrentBrowsingDirectory()

    getCurrentBrowsingDirectory

    File getCurrentBrowsingDirectory()
    Returns the current browsing directory, that is: the directory that will be current the next time the file chooser is opened. It is initialized with the browsingDirectory applet parameter. Then, it contains the last directory used in the file chooser.

    Returns:
    The directory that will be the current one, the next time the file chooser is opened.

    getDateFormat

    String getDateFormat()
    Returns the currently choosen format for date. It must be compatible with the SimpleDateFormat standard Java class.

    Returns:
    The date format.

    setDebugLevel

    void setDebugLevel(int debugLevel)
    This method indicate whether or not the debug messages must be displayed. Default is no debug (0).
    To activate the debug, add a 'debugLevel' parameter to the applet (with 1 to n value), or call this method. Currently, level used in the code are between 0 (no debug) and 100 (max debug).
    With a 0 value, no debug messages will be displayed. The DefaultUploadPolicy.addMsgToDebugBufferString method stores all debug output in a BufferString.

    Parameters:
    debugLevel - The new debugLevel.
    See Also:
    DefaultUploadPolicy.sendDebugInformation(String, Exception)

    getDebugLevel

    int getDebugLevel()
    This method returns the current debug level.

    Returns:
    The current debug level
    See Also:
    setDebugLevel(int)

    getFileChooserIconFromFileContent

    int getFileChooserIconFromFileContent()
    Getter for the fileChooserIconFromFileContent applet parameter.

    Returns:
    Stored value for fileChooserIconFromFileContent
    See Also:
    PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT

    getFileChooserIconSize

    int getFileChooserIconSize()
    Getter for the fileChooserIconSize applet parameter.

    Returns:
    Stored value for fileChooserIconSize
    See Also:
    PROP_FILE_CHOOSER_ICON_SIZE

    getFilenameEncoding

    String getFilenameEncoding()
    Returns the encoding that should be used for the filename. This encoding has no impact on the content of the file that will be uploaded.

    Returns:
    The encoding name, like UTF-8 (see the Charset JDK documentation).

    getFtpCreateDirectoryStructure

    boolean getFtpCreateDirectoryStructure()
    Returns the current value for the ftpCreateDirectoryStructure applet parameter.

    Returns:
    The current value of ftpCreateDirectoryStructure

    getFtpTransfertBinary

    boolean getFtpTransfertBinary()
    Returns the current value for the ftpTransfertBinary applet parameter.

    Returns:
    The current value of ftpTransfertBinary

    getFtpTransfertPassive

    boolean getFtpTransfertPassive()
    Returns the current value for the ftpTransfertPassive applet parameter.

    Returns:
    The current value of ftpTransfertPassive

    setLang

    void setLang(String lang)
    This method sets the current language to take into account. It loads the lang resourceBundle, which will allow the applet to display the texts in the correct language.

    Parameters:
    lang - The new language to take into account. See the java.util.Locale(String) constructor for a list of valid values.

    getMaxChunkSize

    long getMaxChunkSize()
    Returns the value of the applet parameter maxChunkSize (see above for a description of all applet parameters)

    Returns:
    the current value of maxChunkSize.

    getMaxFileSize

    long getMaxFileSize()
    Returns the value of the applet parameter maxFileSize (see above for a description of all applet parameters)

    Returns:
    the current value of maxFileSize.

    getNbFilesPerRequest

    int getNbFilesPerRequest()
    This function returns the number of files should be uploaded during one access to the server. If negative or 0, all files are to be uploaded in one HTTP request. If positive, each HTTP upload contains this number of files. The last upload request may contain less files.
    Examples :

    Returns:
    Returns the maximum number of files, to download in one HTTP request.

    getReadUserAgentFromNavigator

    boolean getReadUserAgentFromNavigator()
    Return the current value of readUserAgentFromNavigator

    Returns:
    Current value of readUserAgentFromNavigator

    getReadCookieFromNavigator

    boolean getReadCookieFromNavigator()
    Return the current value of readCookieFromNavigator

    Returns:
    Current value of readCookieFromNavigator

    getPostURL

    String getPostURL()
    Get the target URL for upload.

    Returns:
    Should be valid URL...

    setPostURL

    void setPostURL(String postURL)
                    throws JUploadException
    The URL can change during the life of our policy ...

    Parameters:
    postURL -
    Throws:
    JUploadException

    getAfterUploadTarget

    String getAfterUploadTarget()
    Return the target, specified as applet parameter "afterUploadTarget"

    Returns:
    the specified target.

    getServerProtocol

    String getServerProtocol()
    HTTP protocol that should be used to send the HTTP request. Currently, this is mainly used by CoppermineUploadPolicy, as the coppermine control that the protocol used for each HTTP request is the same as the one used during the session creation. It is used in the default policy, as it could be used elsewhere.
    Default is : HTTP/1.1

    Returns:
    The selected server protocol.

    setServerProtocol

    void setServerProtocol(String serverProtocol)
    Parameters:
    serverProtocol - The protocol is set from the postURL. For HTTP URL, a HEAD request is done toward the server, to check if any temporary redirection is occuring.

    getSslVerifyCert

    int getSslVerifyCert()
    Retrieves SSL verification mode.

    Returns:
    The current SSL verification mode.

    setShowLogWindow

    void setShowLogWindow(String showLogWindow)
    Parameters:
    showLogWindow - The show window status to set.
    See Also:
    getShowLogWindow()

    getShowLogWindow

    String getShowLogWindow()
    Indicate whether the log window should be shown. It may be convenient to hide it, as it contains mostly debug information. But it still is the only place where possible errors and warnings are shown.
    Default is : true

    Returns:
    The current value for the showStatusBar applet parameter.

    getSpecificHeaders

    String getSpecificHeaders()
    Returns the list of specific headers, that will be added to all HTTP request to the server.

    Returns:
    List of specific headers, with a \r\n at the end of each header.

    getUploadFilename

    String getUploadFilename(FileData fileData,
                             int index)
                             throws JUploadException
    Get the original name of the file on the disk. This function can encode the filename (see the filenameEncoding parameter). By default, the original filename is returned.

    Parameters:
    fileData - The file data whose upload file name must be calculated.
    index - index of the file in the current request to the server (from 0 to n)
    Returns:
    The filename the is given in the filename part of the Content-Disposition header.
    Throws:
    JUploadException

    getUploadName

    String getUploadName(FileData fileData,
                         int index)
                         throws JUploadException
    Get an upload filename, that is to be send in the HTTP upload request. This is the name part of the Content-Disposition header. That is: this is the name under which you can manage the file (for instance in the _FILES[$name] in PHP) and not the filename of the original file.
    If you're using one of the core JUpload UploadPolicy, the value for this parameter is controled by the applet parameters: targetPictureFormat and keepOriginalFileExtensionForConvertedImages.

    Parameters:
    fileData - The file data whose upload name must be calculated.
    index - index of the file in the current request to the server (from 0 to n)
    Returns:
    The name part of the Content-Disposition header.
    Throws:
    JUploadException
    See Also:
    getUploadFilename(FileData, int)

    getUrlToSendErrorTo

    String getUrlToSendErrorTo()
    Returns the current URL where error log must be posted. See Parameters

    Returns:
    the urlToSendErrorTo

    setUrlToSendErrorTo

    void setUrlToSendErrorTo(String urlToSendErrorTo)
                             throws JUploadException
    Parameters:
    urlToSendErrorTo - the urlToSendErrorTo to set
    Throws:
    JUploadException

    getStringUploadError

    String getStringUploadError()
    Retrieve the regular expression that will be tested against each line of the server answer. If one line matches this expression, that upload is marked as failed.

    Returns:
    The regular expression that must be run again each line of the http answer.

    getStringUploadSuccess

    String getStringUploadSuccess()
    Get the regular expression that will be tested against each line of the server answer. If one line matches this expression, that upload is marked as successful.
    The upload works this way:
    1. Upload the selected file(s) to the server
    2. Get all the server HTTP response.
    3. The stringUploadSuccess regular expression is tested against each line from the server.
    4. If the above test gives a match, the upload is marked as successful. Else, the upload is marked as unsuccessful, and a JUploadExceptionUploadFailure is thrown.

    Returns:
    The regular expression that must be run again each line of the http answer.

    getStringUploadWarning

    String getStringUploadWarning()
    Retrieve the regular expression that will be tested against each line of the server answer. If one line matches this expression, a warning message is displayed to the user.

    Returns:
    The regular expression that must be run again each line of the http answer.
    See Also:
    getStringUploadError(), getStringUploadSuccess()

    getFormdata

    String getFormdata()
    Retrieve the applet's "formdata" parameter.

    Returns:
    The applet's formdata parameter.

    getHttpUploadParameterName

    String getHttpUploadParameterName()
    Retrieve the applet's "httpUploadParameterName" parameter.

    Returns:
    The applet's httpUploadParameterName parameter.

    getHttpUploadParameterType

    String getHttpUploadParameterType()
    Retrieve the applet's "httpUploadParameterType" parameter.

    Returns:
    The applet's httpUploadParameterType parameter.

    afterFileDropped

    void afterFileDropped(DropTargetDropEvent dropEvent)
    Reaction by the upload policy, once the management of the dropped file(s) is finished, that is: after all the dropped files have been successfully added to the file list.

    Parameters:
    dropEvent - The event containing the dropped file

    createFileChooser

    JUploadFileChooser createFileChooser()
    The creation of the file chooser is controled by the upload policy, to allow fine control of the way to select files. For instance, the PictureUploadPolicy creates a file chooser, and add an accessory to preview pictures.

    Returns:
    Return the specific file choose, according to this upload policy.

    fileFilterAccept

    boolean fileFilterAccept(File file)
    This methods is called by the JUploadFileFilter.accept(File). It allows the current upload policy to filter files, according to any choosen applet behaviour. This filter applied only when using the fileChooser. Files dropped onto the applet won't trigger this function.
    In the DefaultUploadPolicy upload policy, this filter is based on the applet parameter: allowedFileExtensions.

    Parameters:
    file - Allows the applet to filter files from the file chooser.
    Returns:
    true or false, whether the file is accepted or not.
    See Also:
    JUploadPanel.JUploadPanel(wjhk.jupload2.gui.JUploadTextArea, UploadPolicy)

    fileFilterGetDescription

    String fileFilterGetDescription()
    Return a description for the FileFilter, according to the current upload policy.

    Returns:
    A description for the current filter

    fileViewGetIcon

    Icon fileViewGetIcon(File file)
    Response for the JUploadFileView.getIcon(File). Default is implemented in DefaultUploadPolicy.fileViewGetIcon(File), by returning null, which displays the default icon.

    Parameters:
    file - The file from which the icon should represent.
    Returns:
    The resulting icon.

    setWaitCursor

    Cursor setWaitCursor()
    This method changes the current mouse cursor to the wait one. It returns the old one so that, it can be restored, once the work is done.

    Returns:
    The cursor that was active, before changing to the wait one.
    See Also:
    setCursor(Cursor)

    setCursor

    Cursor setCursor(Cursor cursor)
    Changes the current mouse cursor. This method can be called at the end of a big treatement, to restore the cursor returned by the setWaitCursor().

    Parameters:
    cursor - The cursor that must be set.
    Returns:
    The cursor that was active before setting the new one. Can be used to restore its previous state.

    sendDebugInformation

    void sendDebugInformation(String reason,
                              Exception exception)
    This method allows the applet to post debug information to the website (see getUrlToSendErrorTo()). Then, it is possible to log the error, to send a mail...

    Parameters:
    reason - A string describing briefly the problem. The mail subject will be something like: Jupload Error (reason)
    exception - The java exception that was raised, or null if no exception.

    displayErr

    void displayErr(Exception e)
    log an error message, based on an exception. Will be logged in the log window, if defined.
    The dialog box will only contain an Ok button. Same as caling: displayErr(e, JOptionPane.OK_OPTION);

    Parameters:
    e - The exception to report

    displayErr

    int displayErr(String err,
                   Exception e,
                   int optionType)
    log an error message, based on an exception. Will be logged in the log window, if defined.

    Parameters:
    err - The erreur message to be displayed. If null the exception (or it's cause if any) message is displayed.
    e - The exception to report
    optionType - One of the valid JOptionPane option types for the JOptionPane.showConfirmDialog(java.awt.Component, Object, String, int) method: OK_CANCEL_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION... -1 is also accepted, to only have the Ok button. OK_OPTION is prohibited, as it has the same value as YES_NO_OPTION.
    Returns:
    The XXX_OPTION, corresponding to the button clicked by the user.

    displayErr

    void displayErr(String err)
    log an error message. Will be logged in the log window, if defined.
    The dialog box will only contain an Ok button.

    Parameters:
    err - The erreur message to be displayed.

    displayErr

    void displayErr(String err,
                    Exception e)
    log an error message. Will be logged in the log window, if defined.
    The dialog box will only contain an Ok button.

    Parameters:
    err - The error message to be displayed.
    e - An exception. It's stacktrace is logged.

    displayInfo

    void displayInfo(String info)
    log an info message. Will be logged in the log window, if defined.

    Parameters:
    info - The information message that will be displayed.

    displayWarn

    void displayWarn(String warn)
    log a warning message. Will be logged in the log window, if defined.

    Parameters:
    warn - The warning message that will be displayed.

    displayDebug

    void displayDebug(String debug,
                      int minDebugLevel)
    log a debug message. Will be logged in the log window, if defined.

    Parameters:
    debug - The message to display.
    minDebugLevel - If the current debug level is superior or equals to minDebugLevel, the message will be displayed. Otherwise, it will be ignored.

    addHeader

    void addHeader(String header)
    Add an header to the list of headers that will be added to each HTTP upload request. This method is called from specific uploadPolicies, which would need headers to be added to all uploads. These headers are used in DefaultUploadPolicy.

    Parameters:
    header -
    See Also:
    onAppendHeader(ByteArrayEncoder)

    onAppendHeader

    wjhk.jupload2.upload.helper.ByteArrayEncoder onAppendHeader(wjhk.jupload2.upload.helper.ByteArrayEncoder sb)
                                                                throws JUploadIOException
    Append specific headers for this upload (session cookies, for instance). This method is called while building each upload HTTP request.

    Parameters:
    sb - The header ByteArrayEncoder where specific headers should be appended.
    Returns:
    The ByteArrayEncoder given in parameters. This is allows to work like with StringBuffer.append method: sb.append(s1).append(s2);
    Throws:
    JUploadIOException
    See Also:
    addHeader(String), FileUploadThread

    onFileSelected

    void onFileSelected(FileData fileData)
    This method is called each time a file is selected in the panel files. It allows, for instance, to preview a picture PictureUploadPolicy.

    Parameters:
    fileData -

    onFileDoubleClicked

    void onFileDoubleClicked(FileData fileData)
    Reaction when the user double click on a file, in the file list. Default is no reaction. In PictureUploadPolicy, it will open a PictureDialog.

    Parameters:
    fileData -

    beforeUpload

    boolean beforeUpload()
    Execute any action, that must be done before upload. For instance, PictureUploadPolicy disable the rotation buttons during buttons. The DefaultUploadPolicy.beforeUpload() method just returns true.

    Returns:
    indicate if everything is ready for upload.

    checkUploadSuccess

    boolean checkUploadSuccess(int status,
                               String msg,
                               String body)
                               throws JUploadException
    This method returns true, if upload is a success. A HTTP response of "200 OK" indicates that the server response is techically correct. But, it may be a functionnal error. For instance, the server could answer by a proper HTTP page, that the user is no allowed to upload files. It's up to the uploadPolicy to check this, and answer true or false to this method.
    This method is called once for each HTTP request toward the server. For instance, if the upload is done file by file, and there are three files to upload, this method will be called three times.
    So this method is different from the afterUpload(Exception, String), that will be called only once in this case, after the three calls to the checkUploadSuccess method.

    Parameters:
    status - The numeric response status (e.g. 200)
    msg - The status message from the first line of the response (e.g. "200 OK").
    body - The http body part (that is: the serverOuput without the http headers and the blank line that follow them).
    Returns:
    true (or an exception is raised, instead of returning false). This garantees that all cases are handled: the compiler will indicate an error if the code can come to the end of the method, without finding a 'return' or a throw exception. This return code can be ignored by the caller.
    Throws:
    JUploadException - Thrown if the success conditions are not met.

    afterUpload

    void afterUpload(Exception e,
                     String serverOutput)
                     throws JUploadException
    This method is called after an upload, whether it is successful or not. This method is called once for each click of the user on the 'upload' button. That is: if the nbFilesPerRequest is 2, and the user selected 5 files before clicking on the 'upload' button. Then the afterUpload is called once the 5 files were uploaded to the server.

    Parameters:
    e - null if success, or the exception indicating the problem.
    serverOutput - The full server output, including the HTTP headers.
    Throws:
    JUploadException

    getLocalizedString

    String getLocalizedString(String key,
                              Object... args)
    Retrieve a lang string, based on the file cointained in the wjhk.jupload2.lang package. This allows localization.

    Parameters:
    key - The key, whose associated text is to retrieve. This text must respect the constraints of the String.format(String, Object...) method, that is called in the DefaultUploadPolicy.getLocalizedString(String, Object...) implementation of this method.
    args - The optional parameters, that will replace the placeholders in the localized text identified by 'key'.
    Returns:
    The associated text.

    alert

    void alert(String key)
    Displays a MessageBox with a unique 'Ok' button, by calling the JOptionPane.showMessageDialog(java.awt.Component, Object) method.

    Parameters:
    key - The string identifying the text to display, depending on the current language.
    See Also:
    alertStr(String)

    alertStr

    void alertStr(String str)
    Displays a MessageBox with a unique 'Ok' button, by calling the JOptionPane.showMessageDialog(java.awt.Component, Object) method.

    Parameters:
    str - The full String that must be displayed to the user.
    See Also:
    alert(String)

    confirmDialogStr

    int confirmDialogStr(String str,
                         int optionTypes)
    Displays a MessageBox with a unique 'Ok' button, by calling the JOptionPane.showConfirmDialog(java.awt.Component, Object, String, int) method.

    Parameters:
    str - The full String that must be displayed to the user.
    optionTypes - The options indicating the button to display. Valid options are the options valid for the JOptionPane.showConfirmDialog(java.awt.Component, Object, String, int) method.
    Returns:
    The JOptionConstant that indicates the button the user cliecked on (for instance OK_OPTION)
    See Also:
    alert(String)

    getLastException

    JUploadException getLastException()
    Indicates that an error occurs.

    Returns:
    The last Exception that occurs in the applet. null if no exception occurs.

    getLastResponseBody

    String getLastResponseBody()
    Retrieve the body of the last server response.

    Returns:
    The string containing the last server response (body);

    getLastResponseMessage

    String getLastResponseMessage()
    Retrieve the status/error message of the last server response.

    Returns:
    The string containing either the last server status or (if the error regex matches, the parsed error message.