David Normington
David Normington

Reputation: 847

Cordova 3.4 resolveLocalFileSystemURI on file:// uri

I run the following using Cordova 3.4 on Android using the Genymotion emulator:

window.resolveLocalFileSystemURL('file:///storage/emulated/0/DCIM/Camera/1394726081689.jpg', function(entry) {
    console.log(entry.fullPath);
    console.log(entry.toURL());
    entry.file(fileSuccess, fail);
});

I get the following in the logcat:

I/chromium( 3022): [INFO:CONSOLE(28)] "file:///storage/emulated/0/DCIM/Camera/1394726081689.jpg", source: file:///android_asset/www/js/pdf.js (28)
I/chromium( 3022): [INFO:CONSOLE(29)] "cdvfile://localhost/temporary/file://storage/emulated/0/DCIM/Camera/1394726081689.jpg", source: file:///android_asset/www/js/pdf.js (29)
W/System.err( 2928): java.io.FileNotFoundException: File: cdvfile://localhost/persistent/file://storage/emulated/0/DCIM/Camera/1394726081689.jpg does not exist.
W/System.err( 2928):    at org.apache.cordova.file.FileUtils.getFileMetadata(FileUtils.java:953)
W/System.err( 2928):    at org.apache.cordova.file.FileUtils.access$400(FileUtils.java:53)
W/System.err( 2928):    at org.apache.cordova.file.FileUtils$14.run(FileUtils.java:220)
W/System.err( 2928):    at org.apache.cordova.file.FileUtils$23.run(FileUtils.java:325)
W/System.err( 2928):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err( 2928):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err( 2928):    at java.lang.Thread.run(Thread.java:841)

The same code runs fine on iOS. I've tried only passing this portion to resolveLocalFileSystemURL:

DCIM/Camera/1394726081689.jpg 

in hope that entry.file would use this url:

cdvfile://localhost/temporary/DCIM/Camera/1394726081689.jpg

But that returns a missing protocol error.

I'm sure this is a bug but I would like someone to confirm this please. Thanks!

Upvotes: 3

Views: 5371

Answers (1)

Harry Moreno
Harry Moreno

Reputation: 11603

Yep it's a bug that was fixed in cordova 3.5.0 https://issues.apache.org/jira/browse/CB-5398 I'm waiting on it to be released myself.

Upvotes: 1

Related Questions