file - 从离子4中的文件系统中删除文件
问题描述
我正在使用一个应用程序来创建离线 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 中。
知道如何删除文件吗?
解决方案
推荐阅读
- spring - Spring Integration TCP 侦听同一套接字上的第二个响应
- xml - PHP Doctrine:使用自定义 DBAL 类型的 embbebed 和实体 id 等相同类的问题
- javascript - React.JS 上下文 API 问题(渲染问题)
- r - 我想使用 URL 地址来抓取 24 个网页
- flutter - Flutter - 按下登录按钮后导航到主页不起作用
- java - 如何在 Java 中应用 Excel 自动筛选?
- python - 分析来自魔兽世界 API 的数据
- python - Python - 连接 8 位字以形成 24 位字
- virtual-machine - 使用硬件虚拟机而不是仿真的假设的 DOSBox 类应用程序
- r-markdown - RMarkdown 中的 ioslides_presentation:如何使用徽标和颜色填充自定义幻灯片标题