Overview
In some cases, there is no need to compress data in the archive, for example, if it is pictures or videos in a compressed format, or other data that is already compressed in one way or another. In this case, it is reasonable to save the archive without compression, in "store" mode. Our library offers several options for solving a similar problem, using different formatsZIP
To create a Zip archive, you must use the special class StoreCompressionSettings when creating an Archive instance
with io.FileIO("archive.zip", 'x') as zipFile:
store_settings = zp.saving.ArchiveEntrySettings(zp.saving.StoreCompressionSettings())
with zp.Archive(store_settings) as archive:
archive.create_entry("alice29.txt", "alice29.txt")
archive.create_entry("asyoulik.txt", "asyoulik.txt")
archive.save(zipFile)
This code demonstrates how to create a new ZIP archive named "archive.zip" without compression. It achieves this by creating a ZIP archive object for writing and then adds two specific text files, "alice29.txt" and "asyoulik.txt", to the archive.
7ZIP
For the 7Z format, the approach is similar to the previous one, except that a different class is used for compression settings - SevenZipStoreCompressionSetting
with io.FileIO("archive.7z", 'x') as szFile:
store_settings = zp.saving.SevenZipEntrySettings(zp.saving.SevenZipStoreCompressionSettings())
with zp.sevenzip.SevenZipArchive(store_settings) as archive:
archive.create_entry("alice29.txt", "alice29.txt")
archive.create_entry("asyoulik.txt", "asyoulik.txt")
archive.save(szFile)
This code works similarly to the previous one, with the only difference being that a 7Z format archive will be created as a result.
XAR
If you prefer Mac-OS friendly formats, in a similar way, you can create a Xar archive using the XarStoreCompressionSettings settings class
with io.FileIO("joint.xar", 'x') as xarFile:
store_settings = zp.saving.XarStoreCompressionSettings()
with zp.xar.XarArchive(store_settings) as archive:
archive.create_entry("text.txt", "text.txt")
archive.create_entry("picture.png", "picture.png")
archive.save(xarFile)
TAR
The TAR format was originally created as a means of simply merging several files into one for Unix-based platforms. So if you want to use the TAR format, you just need to create a TarArchive instance without any additional configuration
with io.FileIO("joint.tar", 'x') as tarFile:
with zp.tar.TarArchive() as archive:
archive.create_entry("text.txt", "text.txt")
archive.create_entry("picture.png", "picture.png")
archive.save(tarFile)
CPIO
You can use CpioArchive instead of TarArchive. The usage is completely similar to the previous example:
with io.FileIO("joint.tar", 'x') as cpioFile:
with zp.cpio.CpioArchive() as archive:
archive.create_entry("text.txt", "text.txt")
archive.create_entry("picture.png", "picture.png")
archive.save(cpioFile)
The provided code examples demonstrate how, by using the aspose.zip library, you can easily and efficiently store any number of files in an uncompressed archive. This approach ensures the speed of operations and increases the convenience of working with files. Thanks to this, you will be able to quickly create archives in ZIP, 7Z, TAR, XAR, and CPIO formats, which is useful for organizing and transferring files in various situations.
Other Supported Aspose.ZIP for Python.Net API Features
With the Aspose.ZIP library in Python.Net, you can seamlessly handle various tasks related to ZIP file documents. Whether you need to convert formats, merge files, edit contents, or extract data, Aspose.ZIP provides comprehensive functionality to streamline your workflow and enhance productivity.
Support and Learning Resources
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Release Notes
- Why Aspose.Zip for Python.Net?
- Customers List
- Success Stories