zip2 1.0.0 copy "zip2: ^1.0.0" to clipboard
zip2: ^1.0.0 copied to clipboard

A small zip library totally based on stream and transformer.

A small zip library totally based on stream and transformer.

Usage #

  • zip a file
import 'dart:convert';
import 'dart:io';

import 'package:zip2/zip2.dart';

void main() async {
  final data = File('large.txt').openRead();
  final archive = ZipArchive([
    ZipFileEntry(
      name: 'hello.txt',
      data: Stream.fromIterable([
        utf8.encode('Hello, Dart Zip Package!'),
      ]),
      method: ZipMethod.stored, // STORED (no compression)
    ),
    ZipFileEntry(
      name: 'large.txt',
      data: data,
      method: ZipMethod.deflated, // DEFLATED
    ),
  ]);
  await archive.zip().pipe(File('example.zip').openWrite());
}
  • unzip a file
import 'dart:io';

import 'package:zip2/zip2.dart';

void main() async {
  final file = await File('example.zip').open();
  final archive = file.unzip();
  final entry = archive['hello.txt'];
  await entry?.data.pipe(File('hello.txt').openWrite());
}

also cli commands are available.

  • zip a file
dart bin/zip.dart example.zip a.txt b.docx
  • unzip a file
dart bin/unzip.dart example.zip
0
likes
160
points
53
downloads

Publisher

unverified uploader

Weekly Downloads

A small zip library totally based on stream and transformer.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

path

More

Packages that depend on zip2