Skip to content

Latest commit

 

History

History
74 lines (59 loc) · 1.59 KB

README.md

File metadata and controls

74 lines (59 loc) · 1.59 KB

Nativescript zip

ns plugin add @nativescript/zip

Usage

Zip

import { Zip } from "@nativescript/zip";
import { path, knownFolders } from "@nativescript/core";
let zipPath = path.join(knownFolders.temp().path, "stuff.zip");
let dest = path.join(knownFolders.documents().path, "/assets");
Zip.zip({
    folder: zipPath,
    directory: dest
});

Progress

import { Zip } from "@nativescript/zip";
import { path, knownFolders } from "@nativescript/core";
let zipPath = path.join(knownFolders.temp().path, "stuff.zip");
let dest = path.join(knownFolders.documents().path, "/assets");
Zip.zip({
    folder: zipPath,
    directory: dest,
    onProgress: onZipProgress
});

function onZipProgress(percent: number) {
    console.log(`unzip progress: ${percent}`);
}

Unzip

import { Zip } from "@nativescript/zip";
import { path, knownFolders } from "@nativescript/core";
let zipPath = path.join(knownFolders.temp().path, "stuff.zip");
let dest = path.join(knownFolders.documents().path, "/assets");
Zip.unzip({
    archive: zipPath,
    directory: dest
});

Progress

import { Zip } from "@nativescript/zip";
import { path, knownFolders } from "@nativescript/core";
let zipPath = path.join(knownFolders.temp().path, "stuff.zip");
let dest = path.join(knownFolders.documents().path, "/assets");
Zip.unzip({
    archive: zipPath,
    directory: dest,
    onProgress: onUnZipProgress
});

function onUnZipProgress(percent: number) {
    console.log(`unzip progress: ${percent}`);
}

License

Apache License Version 2.0