Javascript Phonegap/Cordova检查带有特殊字符的文件
我想在应用程序第一次启动时下载所需的图像。我在下载之前检查文件是否存在,但在某些特殊字符方面有问题。空格似乎是自动编码的,但我如何检查一个名为file:///data/data/de.test.app/files/data/img/Pre+ƒ-test.jpg?我检查文件(在我确保deviceready事件触发后)时使用: 我试过了Javascript Phonegap/Cordova检查带有特殊字符的文件,javascript,android,cordova,phonegap-build,Javascript,Android,Cordova,Phonegap Build,我想在应用程序第一次启动时下载所需的图像。我在下载之前检查文件是否存在,但在某些特殊字符方面有问题。空格似乎是自动编码的,但我如何检查一个名为file:///data/data/de.test.app/files/data/img/Pre+ƒ-test.jpg?我检查文件(在我确保deviceready事件触发后)时使用: 我试过了 path = "file:///data/data/de.test.app/files/data/img/Pre+ƒ-test.jpg"; path = "file
path = "file:///data/data/de.test.app/files/data/img/Pre+ƒ-test.jpg";
path = "file:///data/data/de.test.app/files/data/img/Pre%2B%C6%92-test.jpg";
你的文件插件版本是什么?我在File plugin 1.3中遇到了类似的问题,并解决了这个问题:
public LocalFilesystemURL filesystemURLforLocalPath(String localPath) {
LocalFilesystemURL localURL = null;
int shortestFullPath = 0;
for (Filesystem fs: filesystems) {
if (fs != null) {
//LocalFilesystemURL url = fs.URLforFilesystemPath(localPath);
LocalFilesystemURL url = fs.URLforFilesystemPath(Uri.encode(localPath, "/"));
if (url != null) {
if (localURL == null || (url.fullPath.length() < shortestFullPath)) {
localURL = url;
shortestFullPath = url.fullPath.length();
}
}
}
}
return localURL;
}
public LocalFilesystemURL filesystemURLforLocalPath(字符串localPath){
LocalFilesystemURL localURL=null;
int shortestFullPath=0;
for(文件系统fs:文件系统){
如果(fs!=null){
//LocalFilesystemURL=fs.urlforFileSystemTransfer(localPath);
LocalFilesystemURL=fs.urlforFileSystemPassport(Uri.encode(localPath,“/”);
如果(url!=null){
if(localURL==null | |(url.fullPath.length()
public LocalFilesystemURL filesystemURLforLocalPath(String localPath) {
LocalFilesystemURL localURL = null;
int shortestFullPath = 0;
for (Filesystem fs: filesystems) {
if (fs != null) {
//LocalFilesystemURL url = fs.URLforFilesystemPath(localPath);
LocalFilesystemURL url = fs.URLforFilesystemPath(Uri.encode(localPath, "/"));
if (url != null) {
if (localURL == null || (url.fullPath.length() < shortestFullPath)) {
localURL = url;
shortestFullPath = url.fullPath.length();
}
}
}
}
return localURL;
}