- Compression features -


JFileUpload allows compressing files before upload. It can compress each file as ZIP or GZIP before upload. It can also compress all files in one archive and then upload the overall ZIP archive.

Unit compression

Each file could be compressed before upload. Compression formats available are ZIP and GZIP. ".zip" or ".gz" extension will be appended to uploaded filename.

  • To enable ZIP compression:
      <PARAM NAME="ziponfly" VALUE="true">
  • To enable GZIP compression:
      <PARAM NAME="ziponfly" VALUE="gzip">

Compressing files such as MP3, JPEG, GIF is not efficient because these formats are already compressed. JFileUpload allows skipping compression for these thanks to zipignorelist parameter. For instance: <PARAM NAME="zipignorelist" VALUE="*.zip,*gif,*.mp3,*.wmv">

Front-end could display some information about compression on each file. You can modify, comment/uncomment the following properties in i18n.properties:

  • In main panel:
      taskoutput.compress.started=Zipping : {0} ...
      taskoutput.compress.completed=Ratio={0}%
      taskoutput.compress.failed=failed : {0}
      taskoutput.upload.info=Uploading : {0}

  • In progress bar:
      progress.bar.upload.compress.started=Compressing : {0} ...
      progress.bar.upload.compress.completed=Compression completed
      progress.bar.upload.compress.failed=Compression failed : {0}


Overall compression

Instead of compressing each file one by one, JFileUpload allows compressing all files and folders (recursively) in one ZIP archive and then upload this full overall archive. It could be more efficient than unit compression because it saves round-trips with server. The overall archive is created in user's temporary directory and deleted once uploaded. Archive filename is built from first filename (found in the upload list) with ".archive.zip" appended. For instance, if you upload test1.txt, test2.pdf and test3/ folder then the archive uploaded will be named test1.txt.archive.zip.

Add the following parameters to enable overall compression:
  <PARAM NAME="preprocessingfilter" VALUE="archiver">
  <PARAM NAME="folderdepth" VALUE="-1">

Seven additional optional parameters are available:

  • "compressionlevel": Value from 0 to 9. 0 means no compression, 9 means best compression. For instance:
      <PARAM NAME="preprocessingfilterparam1" VALUE="compressionlevel">
      <PARAM NAME="preprocessingfiltervalue1" VALUE="0">


  • "compressioncomment": Insert a comment in the ZIP archive. For instance:
      <PARAM NAME="preprocessingfilterparam2" VALUE="compressioncomment">
      <PARAM NAME="preprocessingfiltervalue2" VALUE="Compressed by JFileUpload">


  • "archiveextension": Default extension appended is .archive.zip. You can modify with this parameter. For instance:
      <PARAM NAME="preprocessingfilterparam3" VALUE="archiveextension">
      <PARAM NAME="preprocessingfiltervalue3" VALUE=".upload.zip">


  • "archivefullname": Archive filename is the name of the first file found with archive extension (see above) appended. You can setup your own archive name with this parameter. For instance:
      <PARAM NAME="preprocessingfilterparam4" VALUE="archivefullname">
      <PARAM NAME="preprocessingfiltervalue4" VALUE="myarchive.zip">


  • "entrytemplate": A renaming template can be applied to each entry in the ZIP archive. "entrytemplate" provide similar behavior as regular "template" parameter. For instance, if you want to replace all non ASCII characters by "_" then use:
      <PARAM NAME="preprocessingfilterparam5" VALUE="entrytemplate">
      <PARAM NAME="preprocessingfiltervalue5" VALUE=":regex=[^a-zA-Z0-9_/\\\\\\-\\.]:_:">

    Notice that this regular expression allows / and \ too for folders and subfolders in ZIP entries.

  • "countrenamed": This parameter allows to enable counting of entries renamed by the entrytemplate above:
      <PARAM NAME="preprocessingfilterparam6" VALUE="countrenamed">
      <PARAM NAME="preprocessingfiltervalue6" VALUE="true">

    Amount of files renamed are available in "entriesrenamed" extra parameter. Remember that extra parameters are sent to server. They're are also available in JavaScript through getExtraParameter("entriesrenamed") function.

  • "archivemaxsize": Maximum size for the ZIP archive. For instance, to setup 10MB as maximum size:
      <PARAM NAME="preprocessingfilterparam7" VALUE="archivemaxsize">
      <PARAM NAME="preprocessingfiltervalue7" VALUE="10485760">

  • "entrylastmodifiedpreserved": This parameter allows preserving file last modified timestamp on archive entries:
      <PARAM NAME="preprocessingfilterparam8" VALUE="entrylastmodifiedpreserved">
      <PARAM NAME="preprocessingfiltervalue8" VALUE="true">


  • "entryfullpathenabled": This parameter allows to using full path (such as c:/folder1/entry1.txt) for each entry in archive:
      <PARAM NAME="preprocessingfilterparam9" VALUE="entryfullpathenabled">
      <PARAM NAME="preprocessingfiltervalue9" VALUE="true">

Notice that "zipignorelist" doesn't apply for overall archive.

Front-end could display some information about compression on each file. You can modify, comment/uncomment the following properties in i18n.properties:

  • In main panel:
      taskoutput.preprocessingfilter.starting=Archiving {0} file(s) ...
      taskoutput.preprocessingfilter.completed=Completed
      taskoutput.preprocessingfilter.failed=Failed {0}

  • In progress bar:
      progress.bar.upload.preprocessingfilter.starting=Archiving {0} file(s)
      progress.bar.upload.preprocessingfilter.started=Archiving in progress, adding file   {0}/{1}
      progress.bar.upload.preprocessingfilter.completed=Archiving completed
      progress.bar.upload.preprocessingfilter.failed=Archiving failed {0}
Compression limitation

Non-ASCII characters such as ÄÜäöüùéàè... are ZIP tools dependent. Java SUN ZIP implementation stores non-ASCII characters as UTF-8. JAVA_HOME/bin/jar.exe tool is able to unzip them. WinZip can't. This known issue is referenced in Java bug database.

Overall progress bar (in i18n.properties) cannot be used with overall compression because all selected files become one ZIP file.

 

Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
All other company and/or product names are the property of their respective owners.