$ cordovaFile removeFile& checkDir错误5(ENCODING_ERR) [英] $cordovaFile removeFile & checkDir error 5 (ENCODING_ERR)

查看:956
本文介绍了$ cordovaFile removeFile& checkDir错误5(ENCODING_ERR)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用$ cordovaFile从Android设备中删除文件。要删除的文件是使用$ cordovaFileTransfer在以下位置下载的。

I am trying to use $cordovaFile to delete files from an Android device. The file to be deleted was downloaded using $cordovaFileTransfer in the following location.

ft.download(url, cordova.file.externalDataDirectory + "episodes/" + episodeId + ".mp3",...);

使用设备上的文件管理器,我可以看到文件位于 file:///storage/emulated/0/Android/data/com.ionicframework.myapp123456/files/episodes/

Using the file manager on the device I can see that the file is located at file:///storage/emulated/0/Android/data/com.ionicframework.myapp123456/files/episodes/

`当我尝试使用以下任一位置来删除文件时,我会收到错误代码5(ENCODING_ERR)

`However when I try to use either of the following locations to delete the file I get error code 5 (ENCODING_ERR)

$cordovaFile.removeFile("file:///storage/emulated/0/Android/data/com.ionicframework.myapp123456/files/episodes/",  "0.mp3")

$cordovaFile.removeFile(cordova.file.externalDataDirectory + "episodes/",  "0.mp3")

当我发生同样的错误尝试使用$ cordovaFile.checkDir(),所以我使用了window.resolveLocalFileSystemURL()。

That same error occurs when I try to use $cordovaFile.checkDir() so I used window.resolveLocalFileSystemURL() instead.

推荐答案

LocalFileSystem。它不像文件插件提供的方法一样,但它可以工作。

This issue was resolved by using the LocalFileSystem. It is not as elegent as the methods provided by the file plugin, but it works.

var uri = cordova.file.externalDataDirectory + "episodes/";

window.resolveLocalFileSystemURL(uri, function(dir) {
        dir.getFile(episodeId + ".mp3", { create: false }, function(file) {
            file.remove(successCallback, errorCallback);
        });
}, errorCallback);

这篇关于$ cordovaFile removeFile& checkDir错误5(ENCODING_ERR)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆