[ 
https://issues.apache.org/jira/browse/CB-5901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13883126#comment-13883126
 ] 

Ian Clelland commented on CB-5901:
----------------------------------

I'm running a couple of tests to try to reproduce this: (Testing using the 
released cordova-plugin-file v0.2.5)

First, creating a file and then requesting it by absolute path:

{code:title=First Test}
requestFileSystem(PERSISTENT, 0, function(fileSystem) {
  console.log("Root fs: " + fileSystem.root.fullPath);
  fileSystem.root.getFile("file.txt", {create: true}, function(entry) {
    console.log(entry.fullPath);
    fileSystem.root.getFile("/storage/emulated/0/file.txt", {create: false, 
exclusive: false},
      function(entry2) {
        console.log(entry2.toURL());
      }, function() {
        console.log("getFile() failed.");
        console.log(JSON.stringify(arguments));
      });
  }, function() {
    console.log("getFile(create) failed.");
    console.log(JSON.stringify(arguments));
  });
}, function() {
  console.log("requestFileSystem failed.");
  console.log(JSON.stringify(arguments));
});
{code}

This logs the fullPath of the created file, and then the toURL of the retrieved 
file:
{code:title=Output}
Root fs: file:///storage/emulated/0
file:///storage/emulated/0/file.txt
file:///storage/emulated/0/file.txt
{code}

Second, by requesting a file at a known absolute path: 

{code:title=Second Test}
requestFileSystem(PERSISTENT, 0, function(fileSystem) {
  console.log("Root fs: " + fileSystem.root.fullPath);
  fileSystem.root.getFile("/system/etc/hosts", {create: false, exclusive: 
false},
    function(entry) {
      console.log(entry.toURL());
    }, function() {
      console.log("getFile() failed.");
      console.log(JSON.stringify(arguments));
    });
}, function() {
  console.log("requestFileSystem failed.");
  console.log(JSON.stringify(arguments));
});
{code}

This just logs the toURL of the retrieved file:

{code:title=Output}
Root fs: file:///storage/emulated/0
file:///system/etc/hosts
{code}

(This second case is actually an error -- the path should be resolved relative 
to the root of the HTML FileSystem, *not* to the actual root of the device 
filesystem -- but that's something I'm fixing in the new version of the File 
plugin)

In no case am I seeing {{localhost}} in the URLs returned, but even if I did, 
it shouldn't be a problem. FileEntry.toURL() is *supposed* to return a URL, 
which in this case should be a file:/// URL.

Sandeep -- is this the same behaviour that you're seeing, or do you see 
something different happening?

> On Android FileEntry.toURL() append extra file://localhost to the file URL
> --------------------------------------------------------------------------
>
>                 Key: CB-5901
>                 URL: https://issues.apache.org/jira/browse/CB-5901
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin File
>    Affects Versions: 3.3.0
>         Environment: Android 4.2
>            Reporter: sandeep paliwal
>            Assignee: Ian Clelland
>            Priority: Minor
>
> The returned URL from the FileEntry object's toURL() method is now of form 
> file://localhostfile:///<actual file path here>. 
> This happens only on Android.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to