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

Ian Clelland commented on CB-6249:
----------------------------------

So the one problem I see with simply returning the file is that there is no 
guarantee that the file exists in a place that is accessible to the File plugin 
(short of mandating that everyone expose the *entire* filesystem to JavaScript 
by installing the file-system-roots plugin, which I'd rather not have to do).

Right now, {{entry.toNativeURL()}} and {{entry.toURL()}} always return a URL 
which can be handled by {{resolveLocalFileSystemURL}}. If we unconditionally 
resolve all content:// URLs to their file representation, that would mean that 
this snippet would fail on some content:// URLs:

{code}
resolveLocalFileSystemURL(contentURL, function(entry) {  // start with a 
content:// url
    var fileURL = entry.toNativeURL();  // turn it into a file:// url, pointing 
to a location outside of the sandbox
    resolveLocalFileSystemURL(fileURL, successCallback);  // fails because the 
file is inaccessible
});
{code}

One way forward would be to opportunistically convert content:// URLs to 
file:// URLs, *if* it can be done (the file exists) and *if* the process is 
reversible (the file could be resolved again to get a cdvfile url), and leave 
all other content:// URLs unchanged.

Alternately, we could ignore that particular issue, since there has never been 
a guarantee that to\*URL / resolveLocalFileSystemURL can round-trip like that, 
and just convert all content URLs which map to files, regardless of whether or 
not the resulting file url can be re-consumed by the file plugin.

(No matter what we do, though, there is never going to be a guarantee that a 
URL returned by {{.toURL()}} or {{.toNativeURL()}} is a file:// URL. Some 
resources are simply not available through that protocol.)

> Camera fails to return an actual FILE_URI it always returns content://
> ----------------------------------------------------------------------
>
>                 Key: CB-6249
>                 URL: https://issues.apache.org/jira/browse/CB-6249
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin Camera, Plugin File
>    Affects Versions: 3.4.0
>         Environment: Current Node Version
>     v0.10.25
> Current Cordova CLI Version
>     3.4.0-0.1.0
> Android
>            Reporter: Ralph S Theart
>              Labels: camera, file
>
> No matter what I do I can not get a url of file:///... all I get is 
> {code}
> content://media/external/images/media/1357
> {code}
> Here is my very simple code....
> {code}
> navigator.camera.getPicture(function(imageURI){
>    console.log('GOT IMAGE: '+imageURI);
>    window.resolveLocalFileSystemURL(imageURI, function(entry){
>       console.log(entry.name + " " +entry.fullPath);
>    }, function(e){
>       console.log('Some error occured: '+e.code);
>    }); 
> }, onPhotoFail, {
>    destinationType: 1, 
>    sourceType: pictureSource,
>    mediaType : Camera.MediaType.ALLMEDIA,
>    encodingType: 0,
>    allowEdit : false,
>    correctOrientation:true,
>    saveToPhotoAlbum: false,
>    quality: 50
> });
> {code}
> I always get content://... for the returned path from camera and even the 
> same thing when I resolve the url. Can you confirm this bug?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to