buh/ZipPinch
Remote access to files inside a ZIP file for macOS, iOS and watchOS.
Getting started
- First you need to create an instance of
URLSession. Then make a request for the contents via a directURLto your ZIP file.
let urlSession = URLSession(configuration: .default)
let entries = try await urlSession.zipEntries(from: url)[!NOTE] You can also add a
URLSessionTaskDelegateor use a customisedURLRequest.
- Download the data of an entry:
let data = try await urlSession.zipEntryData(entry, from: url)- Use the data to initiate an image or other types.
Check out the Hubble demo app to view selected images from the archive taken by The Hubble Space Telescope.
Download with progress
To download with showing the progress, a ZIPProgress object must be specified:
let data = try await urlSession.zipEntryData(entry, from: url, progress: .init() { progressValue in
Task { @MainActor in
self.progress = progressValue
}
})Download folder
- Converting entries to a tree hierarchy with folders and enrties:
let entries = try await urlSession.zipEntries(from: url)
let rootFolder = entries.rootFolder()- Recursively load folder and subfolder entries:
// folderData: [(entry: ZIPEntry, data: Data)]
let folderData = try await urlSession.zipFolderData(folder, from: url)- The same, but with the overall progress:
// folderData: [(entry: ZIPEntry, data: Data)]
let folderData = try await urlSession.zipFolderData(folder, from: url, progress: .init() { progressValue in
Task { @MainActor in
self.progress = progressValue
}
})Features
- [x] Custom
URLRequest - [x] Task management with
URLSessionTaskDelegate - [x] Support for a custom decompressor
- [x] ZIP 64-bit support
- [x] Tracking the downloading progress
- [x] Demo for iPhone/iPad/macOS.
- [x] ZIP entries as a tree of Folders/Files.
- [x] Dowload a folder.
ZIP file format specification sources
- Wikipedia#File_headers)
- PKWARE ZIP File Format Specification
- Fossies
Support
You can buy me a coffee here ☕️
License
ZipPinch is available under the MIT license
Package Metadata
Repository: buh/ZipPinch
Stars: 23
Forks: 4
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
Topics: ios, ipados, macos, msdos, spm, swift, urlsession, watchos, zip
README: README.md