ASPPY.zip
The ASPPY.zip namespace provides simple methods to compress and extract files and folders natively using Python's zipfile module.
Methods
| Method | Description |
|---|---|
Zip(path, [out_path]) |
Zips a file or folder located at physical path. If out_path is not provided, it defaults to path + ".zip". Returns the absolute path to the generated zip file. |
Unzip(zip_path, dest_folder, [overwrite]) |
Extracts the archive zip_path into dest_folder. overwrite defaults to True. Returns the absolute path to the destination folder. |
Sample Code
<%
Dim outZip, extractDir
' 1. Zipping a folder (Server.MapPath translates virtual paths to physical paths)
outZip = ASPPY.zip.Zip(Server.MapPath("/data/reports"), Server.MapPath("/data/reports.zip"))
Response.Write "Zipped to: " & outZip & "<br>"
' 2. Unzipping an archive
extractDir = ASPPY.zip.Unzip(Server.MapPath("/data/reports.zip"), Server.MapPath("/data/extracted"), True)
Response.Write "Extracted to: " & extractDir & "<br>"
%>
Security Note: ASPPY protects against Zip Slip vulnerabilities by preventing path traversal when extracting archives.