Interface ZipUtilsService

All Known Implementing Classes:
ZipUtilsServiceImpl

public interface ZipUtilsService
  • Field Details

    • DIRECTORY_MARKER

      static final Object DIRECTORY_MARKER
      Marks a directory for zipping.
  • Method Details

    • createZip

      void createZip(Map<String,? extends Object> content, OutputStream os) throws IOException
      Packs the given list of files and/or directories into a zip archive.
      Parameters:
      content - map containing the files to zip. In case of zipping files, the key contains the filename, while the value contains the object to be zipped. The object may be a String or a byte array. In case of zipping directories, the key contains the relative directory path, and the value contains DIRECTORY_MARKER. In this case, the files inside the given directory should contain the relative path to the file.

      Example zipping c.txt and mydirectory containing a.txt and b.txt:

      • mydirectory=DIRECTORY_MARKER
      • mydirectory/a.txt="a"
      • mydirectory/b.txt="b"
      • c.txt="c"

      os - the OutputStream where the zip should be written to
      Throws:
      IOException - if an I/O error has occurred
    • createZip

      void createZip(String contentFilename, Object content, OutputStream os) throws IOException
      Packs the given content into a zip archive.
      Parameters:
      contentFilename - the filename of the file to be zipped
      content - the content to be zipped. It may be a String or a byte array
      os - the OutputStream where the zip should be written to
      Throws:
      IOException - if an I/O error has occurred
    • cleanFilename

      String cleanFilename(String filename)
      Replaces invalid characters from a filename to be zipped with valid characters.
      Parameters:
      filename - the filename to be cleaned
      Returns:
      the cleaned filename
    • cleanDirectoryName

      String cleanDirectoryName(String dirname)
      Replaces invalid characters from a directory name to be zipped with valid characters.
      Parameters:
      dirname - the directory name to be cleaned
      Returns:
      the cleaned directory name
    • createZip

      void createZip(List<Path> files, OutputStream os) throws IOException
      Throws:
      IOException
    • createZipFromEmailAttachments

      void createZipFromEmailAttachments(List<SimpleAttachment> attachments, OutputStream os) throws IOException
      Throws:
      IOException
    • extractZip

      void extractZip(byte[] data, ZipExtractionConfig config) throws IOException
      Throws:
      IOException
    • extractZip

      void extractZip(InputStream is, ZipExtractionConfig config) throws IOException
      Throws:
      IOException
    • createZip

      void createZip(byte[] content, OutputStream os) throws IOException
      Throws:
      IOException
    • createZip

      void createZip(FileServerFolder folder, OutputStream os) throws IOException
      Throws:
      IOException
    • createZip

      void createZip(FileServerFolder folder, OutputStream os, ZipUtilsService.FileFilter filter) throws IOException
      Throws:
      IOException