mirror of
https://github.com/xlmnxp/extractify.zip.git
synced 2024-11-23 17:13:12 +03:00
use fs.readFile instead of fs.lookupPath
This commit is contained in:
parent
e28a3be675
commit
22bdaf5741
@ -146,19 +146,18 @@ export class SevenZipManager {
|
|||||||
if (!this.sevenZip) return;
|
if (!this.sevenZip) return;
|
||||||
file = typeof file === "string" ? JSON.parse(file) : file;
|
file = typeof file === "string" ? JSON.parse(file) : file;
|
||||||
|
|
||||||
this.sevenZip.FS.chdir("/");
|
|
||||||
|
|
||||||
// extract file from archive
|
// extract file from archive
|
||||||
this.execute(['x', '-y', this.archiveName, file.path.substring(1)]);
|
this.execute(['x', '-y', this.archiveName, file.path.substring(1)]);
|
||||||
|
this.sevenZip.FS.chmod(file.path, 0o777);
|
||||||
|
|
||||||
const { node } = this.sevenZip.FS.lookupPath('/');
|
// get file buffer
|
||||||
const buffer = node.contents[file.path.substring(1)].contents;
|
const buffer = this.sevenZip.FS.readFile(file.path);
|
||||||
|
|
||||||
const blob = new Blob([buffer as unknown as Uint8Array], { type: mime.getType(file.extension!) || "application/octet-stream" });
|
const blob = new Blob([buffer], { type: mime.getType(file.extension!) || "application/octet-stream" });
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
|
|
||||||
// remove the file after extract local blob url
|
// remove the file after extract local blob url
|
||||||
this.sevenZip.FS.unlink(file.path.substring(1));
|
this.sevenZip.FS.unlink(file.path);
|
||||||
|
|
||||||
return blobUrl;
|
return blobUrl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user