【发布时间】:2019-09-02 15:43:20
【问题描述】:
我正在使用一个应用程序来创建离线 PDF 并将它们保存在文件系统中。 现在的问题是当我删除特定记录时,我需要从文件系统中删除 PDF,我通过文件插件但找不到任何相关的方法。我正在使用 ionic 4 这里有一些代码和平。
if (this.plt.is('cordova')) {
this.pdfObj.getBuffer((buffer) => {
const blob = new Blob([buffer], { type: 'application/pdf' });
// Save the PDF to the data Directory of our App
this.file.writeFile(this.file.externalRootDirectory + '/Downloads/', 'ACCSYS-' +
this.randomString(4) + '-' + encodeURI(this.headerData.title) + '.pdf', blob, { replace: true }).then(fileEntry => {
// Open the PDf with the correct OS tools
setTimeout(() => {
this.hideLoader();
this.fileOpener.open(fileEntry.nativeURL, 'application/pdf');
this.pdfObj = null;
}, 1000);
});
});
} else {
setTimeout(() => {
this.hideLoader();
this.pdfObj.download();
this.pdfObj = null;
}, 500);
}
假设我将 nativeURL 存储在 localstorage 中。
知道如何删除文件吗??
【问题讨论】:
-
您使用哪个插件来访问文件系统?是File plugin 吗?
-
是的,我正在使用文件和文件打开器插件
标签: file ionic-framework ionic4