Package net.datenwerke.rs.utils.zip
Interface ZipUtilsService
- All Known Implementing Classes:
ZipUtilsServiceImpl
public interface ZipUtilsService
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncleanDirectoryName(String dirname) Replaces invalid characters from a directory name to be zipped with valid characters.cleanFilename(String filename) Replaces invalid characters from a filename to be zipped with valid characters.voidcreateZip(byte[] content, OutputStream os) voidcreateZip(String contentFilename, Object content, OutputStream os) Packs the given content into a zip archive.voidcreateZip(List<Path> files, OutputStream os) voidcreateZip(Map<String, ? extends Object> content, OutputStream os) Packs the given list of files and/or directories into a zip archive.voidcreateZip(FileServerFolder folder, OutputStream os) voidcreateZip(FileServerFolder folder, OutputStream os, ZipUtilsService.FileFilter filter) voidcreateZipFromEmailAttachments(List<SimpleAttachment> attachments, OutputStream os) voidextractZip(byte[] data, ZipExtractionConfig config) voidextractZip(InputStream is, ZipExtractionConfig config)
-
Field Details
-
DIRECTORY_MARKER
Marks a directory for zipping.
-
-
Method Details
-
createZip
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 containsDIRECTORY_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"
- mydirectory=
os- the OutputStream where the zip should be written to- Throws:
IOException- if an I/O error has occurred
-
createZip
Packs the given content into a zip archive.- Parameters:
contentFilename- the filename of the file to be zippedcontent- the content to be zipped. It may be a String or a byte arrayos- the OutputStream where the zip should be written to- Throws:
IOException- if an I/O error has occurred
-
cleanFilename
Replaces invalid characters from a filename to be zipped with valid characters.- Parameters:
filename- the filename to be cleaned- Returns:
- the cleaned filename
-
cleanDirectoryName
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
- Throws:
IOException
-
createZipFromEmailAttachments
void createZipFromEmailAttachments(List<SimpleAttachment> attachments, OutputStream os) throws IOException - Throws:
IOException
-
extractZip
- Throws:
IOException
-
extractZip
- Throws:
IOException
-
createZip
- Throws:
IOException
-
createZip
- Throws:
IOException
-
createZip
void createZip(FileServerFolder folder, OutputStream os, ZipUtilsService.FileFilter filter) throws IOException - Throws:
IOException
-