diff --git a/src/export/packer/packer.ts b/src/export/packer/packer.ts index 56d604fe18..fa783234d6 100644 --- a/src/export/packer/packer.ts +++ b/src/export/packer/packer.ts @@ -1,4 +1,5 @@ import { File } from "@file/file"; +import { Stream } from "stream"; import { Compiler } from "./next-compiler"; @@ -45,6 +46,18 @@ export class Packer { return zipData; } + + public static async toStream(file: File, prettify?: boolean | PrettifyType): Promise { + const zip = this.compiler.compile(file, prettify); + const zipData = zip.generateNodeStream({ + type: "nodebuffer", + streamFiles: true, + mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + compression: "DEFLATE", + }); + + return zipData; + } private static readonly compiler = new Compiler(); }