本文整理汇总了TypeScript中@ionic-native/file.File.async方法的典型用法代码示例。如果您正苦于以下问题:TypeScript File.async方法的具体用法?TypeScript File.async怎么用?TypeScript File.async使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ionic-native/file.File
的用法示例。
在下文中一共展示了File.async方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: onProgress
}).then(() => {
const promises = [],
total = Object.keys(zip.files).length;
let loaded = 0;
for (const name in zip.files) {
const file = zip.files[name];
let promise;
if (!file.dir) {
// It's a file.
const fileDir = name.substring(0, name.lastIndexOf('/')),
fileName = name.substr(name.lastIndexOf('/') + 1),
filePromises = [];
let fileData;
if (fileDir) {
// The file is in a subfolder, create it first.
filePromises.push(this.createDir(destination, fileDir));
}
// Read the file contents as a Blob.
filePromises.push(file.async('blob').then((data) => {
fileData = data;
}));
promise = Promise.all(filePromises).then(() => {
// File read and parent folder created, now write the file.
const parentFolder = this.textUtils.concatenatePaths(destination, fileDir);
return this.file.writeFile(parentFolder, fileName, fileData, {replace: true});
});
} else {
// It's a folder, create it if it doesn't exist.
promise = this.createDir(destination, name);
}
promises.push(promise.then(() => {
// File unzipped, call the progress.
loaded++;
onProgress && onProgress({ loaded: loaded, total: total });
}));
}
return Promise.all(promises).then(() => {
return 0;
});
}).catch(() => {