Menu

Importing Bandcamp ZIPs in a Flutter music player: streams, zip slip and Finder junk
📰

Importing Bandcamp ZIPs in a Flutter music player: streams, zip slip and Finder junk

DEV Community: flutter·Felix Helleckes·about 10 hours ago
#DRNhtr70
#devtoflutter#devto#dev#rad#album
Long article (1348 words) — no AI summary yet.
Reading 0:00
15s threshold

People who still buy music mostly get it as a ZIP. Bandcamp, Qobuz and most download shops hand you one archive per album. My offline music player, Clickwheel, could only import loose audio files, so the first thing a new user had to do was find an unzip tool on their phone. That is a bad first minute.

So I added ZIP import. The diff was 469 lines across 13 files, and almost none of it was "call the unzip function". Here is what the rest was.

1. Stream from disk, off the UI thread

A FLAC album is easily several hundred megabytes. Reading it into a Uint8List on a phone is asking for an out-of-memory kill. The archive package (4.x) can decode from a file stream and write each entry straight to disk:

static List < String > unpackZip ( String zipPath , String destPath ) { final input = InputFileStream ( zipPath ) ; final written = < String > [ ] ; try { final archive = ZipDecoder ( ) . decodeStream ( input ) ; for ( final entry in archive ) { if ( ! entry .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.