本文整理匯總了TypeScript中jszip.loadAsync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript loadAsync函數的具體用法?TypeScript loadAsync怎麽用?TypeScript loadAsync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了loadAsync函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: uploadAndParse
private async uploadAndParse(file: File): Promise<boolean> {
let zip;
try {
await this.fs.write("/original.zip", file);
const zipFileEntry = await this.fs.open("/original.zip");
zip = await JSZip.loadAsync(zipFileEntry);
} catch (e) {
this.logger.error(`Could not upload the ZIP file: ${e.message}`);
return false;
}
try {
const annoRoot = findRootInZip(zip);
await this.fs.rmRoot();
await this.copyIslands(annoRoot);
await this.copySaves(annoRoot);
const customMissionPath = await this.parseTranslations(annoRoot);
await this.copyMissions(annoRoot, customMissionPath);
await this.decryptCODs(annoRoot);
await this.parseDATs();
await this.parseGADs(annoRoot);
await this.parseBSHs(annoRoot);
await this.parseZEIs(annoRoot);
await this.parseMusic(annoRoot);
await this.parseVideos(annoRoot);
} catch (e) {
this.logger.error(e.message);
return false;
}
return true;
}
示例2: JSZip
fs.readFile(pathToJar, (err, data) => {
let zip = new JSZip();
zip.loadAsync(data).then((new_zip) => {
new_zip.file(pathToFileInJar).async("string").then((value) => {
resolve(value);
})
})
})
示例3: retrieveZipContentList
export function retrieveZipContentList(filePath: string) {
return JSZip.loadAsync(fs.readFileSync(filePath, 'binary'))
.then((zip) => {
let fileArray = [];
Object.keys(zip.files).forEach((_filename) => {
fileArray.push(_filename);
});
return fileArray;
});
}
示例4: function
reader.onload = function(e) {
const zipBinary = new Uint8Array((e.target as any).result)
const zip = new JSZip()
zip.loadAsync(zipBinary)
.then((loadedZip: JSZip) => {
Object.keys(loadedZip.files).forEach(fileName => {
if (getExt(fileName).toLowerCase() === 'nes') {
loadedZip.files[fileName].async('uint8array')
.then((rom) => { onNesFileLoaded(rom, fileName) })
.catch(error => { console.error(error) })
}
})
})
.catch(error => {
console.error(error)
})
}
示例5:
filereader.onload = (event: any) => {
Zipper.loadAsync(event.target.result).then((data) => {
console.log("data", data.files);
for (var item in data.files) {
console.log("file", item);
if (item == "meta.json") {
Zipper.file('meta.json').async('string').then((data) => {
var contents = JSON.parse(data);
var success = this.JsonService.setData(contents);
console.log(contents);
this.routeHandler(contents);
})
}
}
});
}
示例6: success
file.async("nodebuffer").then(function success(content) {
const jszip = new JSZip();
jszip.loadAsync(content).then((zip) => {
const files = zip.files;
files["Linky.txt"].async("string").then((line: string) => {
const lines = myLines.map((el) => linePrefix + el);
line = line.split(",")[0].replace(/"/g, "");
if (lines.indexOf(line) >= 0) {
const folder = path.basename(file.name, path.extname(file.name));
const destination = path.join(localDataPath, jdfPath, folder);
//todo: delete old folders!
mkdir(destination).then(() => {
const promises: Promise<string>[] = [];
for (let key in files) {
if (files.hasOwnProperty(key)) {
const f = files[key];
const promise = new Promise((resolve, reject) => {
f["nodeStream"]()
.pipe(fs.createWriteStream(path.join(destination, f.name)))
.on("finish", () => {
resolve(f.name);
})
.on("error", (e) => {
reject(e);
});
});
promises.push(promise);
}
}
Promise.all(promises).then(() => {
resolve(file.name);
});
}).catch((e) => {
reject(e);
});
} else {
resolve(null);
}
});
});
}, function error(e) {
示例7: extract
public async extract(data: Buffer): Promise<IDocumentTemplate> {
const zipContent = await JSZip.loadAsync(data);
const documentContent = await zipContent.files["word/document.xml"].async("text");
const relationshipContent = await zipContent.files["word/_rels/document.xml.rels"].async("text");
const documentRefs = this.extractDocumentRefs(documentContent);
const documentRelationships = this.findReferenceFiles(relationshipContent);
const media = new Media();
const templateDocument: IDocumentTemplate = {
headers: await this.createHeaders(zipContent, documentRefs, documentRelationships, media, 0),
footers: await this.createFooters(zipContent, documentRefs, documentRelationships, media, documentRefs.headers.length),
currentRelationshipId: documentRefs.footers.length + documentRefs.headers.length,
styles: await zipContent.files["word/styles.xml"].async("text"),
titlePageIsDefined: this.checkIfTitlePageIsDefined(documentContent),
media: media,
};
return templateDocument;
}
示例8: load
export function load(buffer: ArrayBuffer) {
let zip = new JSZip();
zip.loadAsync(buffer).then((zip: any) => {
let mainfs = zip.folder("mainfs");
mainfs.forEach((relativePath: string, file: any) => {
let dirFileRegex = /(\d+)\/(\d+)/;
let match = relativePath.match(dirFileRegex);
if (!match)
return;
let d = parseInt(match[1]);
let f = parseInt(match[2]);
if (isNaN(d) || isNaN(f))
return;
file.async("arraybuffer").then((content: ArrayBuffer) => {
$$log(`Overwriting MainFS ${d}/${f}`);
mainfs.write(d, f, content);
});
});
}, (error: any) => {
$$log(error);
showMessage(`Something went wrong while loading the zip. ${error}`);
});
}
示例9:
return this.file.readAsArrayBuffer(sourceDir, sourceName).then((data) => {
// Now load the file using the JSZip library.
return zip.loadAsync(data);
}).then((): any => {
示例10: JSZip
.then((buffer: Buffer) => {
const zip = new JSZip()
return zip.loadAsync(buffer)
})