本文整理匯總了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(() => {