本文整理汇总了TypeScript中yazl.ZipFile.addReadStream方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ZipFile.addReadStream方法的具体用法?TypeScript ZipFile.addReadStream怎么用?TypeScript ZipFile.addReadStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yazl.ZipFile
的用法示例。
在下文中一共展示了ZipFile.addReadStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: require
import { ZipFile } from "yazl";
import { Readable } from "stream";
import fs = require('fs');
const zipfile = new ZipFile();
zipfile.addFile("file1.txt", "file1.txt");
// (add only files, not directories)
zipfile.addFile("path/to/file.txt", "path/in/zipfile.txt");
// pipe() can be called any time after the constructor
// $ExpectType Readable
zipfile.outputStream;
zipfile.outputStream.pipe(fs.createWriteStream("output.zip")).on("close", () => {
console.log("done");
});
// alternate apis for adding files:
zipfile.addReadStream(process.stdin, "stdin.txt", {
mtime: new Date(),
mode: parseInt("0100664", 8), // -rw-rw-r--
});
zipfile.addBuffer(new Buffer("hello"), "hello.txt", {
mtime: new Date(),
mode: parseInt("0100664", 8), // -rw-rw-r--
});
// call end() after all the files have been added
zipfile.end();