mirror of
https://github.com/kmitresse/Compo-Service-Log-Project.git
synced 2026-07-09 12:07:45 +00:00
feat!: Download and extract from stream
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import ArchiveExtractor from "./ArchiveExtractor";
|
||||
import unzipper from "unzipper";
|
||||
import { pipeline } from "node:stream";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
class ZipExtractor implements ArchiveExtractor {
|
||||
public static instance: ArchiveExtractor = new ZipExtractor();
|
||||
|
||||
async extract(
|
||||
stream: ReadableStream,
|
||||
destinationPath: string
|
||||
): Promise<void> {
|
||||
const streamPipeline = promisify(pipeline);
|
||||
await streamPipeline(stream, unzipper.Extract({ path: destinationPath }));
|
||||
}
|
||||
}
|
||||
|
||||
export default ZipExtractor;
|
||||
Reference in New Issue
Block a user