Phonegap/Cordova ...拍照后删除临时文件系统

Joh*_*ner 2 image ios cordova

我发现iOS上的Phonegap/Cordova应用程序正在保存我用相机拍摄的所有照片并将它们上传到服务器.

在"使用"点击下的iPhone设置中,即使在退出应用程序后,我的应用程序和所需的磁盘大小也在增加.

那么在将其上传到我的服务器后,如何删除这些临时文件或图片本身呢?我使用pictureURI找到它进行上传.

编辑:谢谢.我已经实现了代码,现在它看起来像这样:

在我的fileupload函数中,我添加了这一行:

window.resolveLocalFileSystemURI(fileURI, onResolveSuccess, faillocal);
Run Code Online (Sandbox Code Playgroud)

其他功能如下:

function onResolveSuccess(fileEntry) {
  console.log(fileEntry.name);
  entry.remove(entrysuccess, failresolve);
}

function entrysuccess(entry) {
  console.log("Removal succeeded");
}

function failresolve(error) {
  alert('Error removing directory: ' + error.code);
}

function faillocal(evt) {
  console.log(evt.target.error.code);
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用.文件已上传,但没有警报,没有控制台写入,根本没有删除...

Sim*_*ald 7

您应该能够获取图片URI并将其传递给window.resolveLocalFileSystemURI,然后在此方法的成功回调中,您将获得一个FileEntry对象,您可以在上调用remove方法.