title: BlackBerry 10, Camera, and FILE_NOT_FOUND_ERR
body: <p>I am trying to run a phonegap app in a new BlackBerry 10 Device (Z10) and I'm running into an issue. Basically, I take a photo and I want to upload it to my server with a FileTransfer, but the FileTransfer fails with a FileTransferError.FILE_NOT_FOUND_ERR.</p>
  
  <p>I then tried using the window.resolveLocalFileSystemURI method, and I now get a FileError.NOT_FOUND_ERR. I am assuming these two errors are related.</p>
  
  <p>The fileURI I am passing to both of these is the fileURI that I get back from the navigator.camera.getPicture success callback and looks something like:</p>
  
  <pre><code>file:///accounts/1000/shared/camera/IMG_00000037.jpg
  </code></pre>
  
  <p>I've taken the example blackberry app from the phonegap 2.5.0 download and modified the index.html slightly to reproduce the issue, which I will include below:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;!--
      Licensed to the Apache Software Foundation (ASF) under one
      or more contributor license agreements.  See the NOTICE file
      distributed with this work for additional information
      regarding copyright ownership.  The ASF licenses this file
      to you under the Apache License, Version 2.0 (the
      "License"); you may not use this file except in compliance
      with the License.  You may obtain a copy of the License at
  
      http://www.apache.org/licenses/LICENSE-2.0
  
      Unless required by applicable law or agreed to in writing,
      software distributed under the License is distributed on an
      "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
       KIND, either express or implied.  See the License for the
      specific language governing permissions and limitations
      under the License.
  --&gt;
  &lt;html&gt;
      &lt;head&gt;      
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
          &lt;meta name="format-detection" content="telephone=no" /&gt;
          &lt;meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /&gt;
          &lt;title&gt;Hello World&lt;/title&gt;
  
          &lt;script type="text/javascript" charset="utf-8"&gt;
  
          // Called when a photo is successfully retrieved
          //
          function onPhotoURISuccess(imageURI, testFunction) {
              // Uncomment to view the image file URI 
              console.log(imageURI);
  
              // Get image handle
              //
              var image = document.getElementById('image');
  
              // Unhide image elements
              //
              image.style.display = 'block';
  
              // Show the captured photo
              // The inline CSS rules are used to resize the image
              //
              image.src = imageURI;
  
              // Run our test function
              testFunction(imageURI);
          }
  
          // Called if something bad happens.
          // 
          function onPhotoURIFail(message) {
              alert('Failed because: ' + message);
          }
  
          // A button will call this function
          //
          function getPhoto(source, testFunction) {
              // un-sandbox file system to access shared folder
              blackberry.io.sandbox = false;
  
              // Retrieve image file location from specified source
              navigator.camera.getPicture(
                  function(imageURI) {
                      onPhotoURISuccess(imageURI, testFunction);
                  },
                  onPhotoURIFail,
                  {
                      quality: 50,
                      destinationType: Camera.DestinationType.FILE_URI,
                      sourceType: source,
                      correctOrientation: true,
                      saveToPhotoAlbum: true
                  }
              );
          }
  
          // Tests whether we can resolve the imageURI returned from navigator.camera.getPicture
          //
          function testResolveLocalFileSystemURI(imageURI) {
              window.resolveLocalFileSystemURI(
                  imageURI,
                  function (fileEntry) {
                      var message = "Resolved local file system URI: " + imageURI;
                      document.getElementById("span").innerHTML = message;
                      console.debug(message);
                      console.debug(fileInfo);
                  },
                  function (error) {
                      var message = "Unable to resolve local file system URI: " + imageURI + " error: " + error.code;
                      document.getElementById("span").innerHTML = message;
                      console.error(message);
                      console.debug(error);
                      console.debug("resolve error source " + error.source);
                      console.debug("resolve error target " + error.target);
                  }
              );
          }
  
          // Tests whether we can upload the imageURI returned from navigator.camera.getPicture using a FileTransfer
          //
          function testFileTransferUpload(imageURI) {
  
              // Create =the file upload options
              var options = new FileUploadOptions();
              options.fileKey="file";
              options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
              options.mimeType="image/jpeg";
  
              // Create the file transfer and upload
              var ft = new FileTransfer();
              ft.upload(
                  imageURI,
                  encodeURI("http://some.server.com/upload.php"),
                  function (r) {
                      var message = "Code: '" + r.responseCode + "'' Response: '" + r.response + "'' Sent: '" + r.bytesSent + "'";
                      document.getElementById("span").innerHTML = message;
                      console.debug(message);
                  },
                  function (error) {
                      var message = "Unable to upload: " + imageURI + " error: " + error.code;
                      document.getElementById("span").innerHTML = message;
                      console.error(message);
                      console.debug(error);
                      console.debug("upload error source " + error.source);
                      console.debug("upload error target " + error.target);
                  },
                  options
              );
          }
  
          // Tests whether we can upload the imageURI returned from navigator.camera.getPicture using a FileTransfer
          //
          function testFileSystemGetFile(imageURI) {
              window.requestFileSystem(
                  LocalFileSystem.PERSISTENT,
                  0,
                  function (fileSystem) {
                      fileSystem.root.getFile(
                          imageURI,
                          {create: false},
                          function (fileEntry) {
                              var message = "Got file: " + imageURI;
                              document.getElementById("span").innerHTML = message;
                              console.debug(message);
                              console.debug(fileInfo);
                          },
                          function (error) {
                              var message = "Unable to get file: " + imageURI + " error: " + error.code;
                              document.getElementById("span").innerHTML = message;
                              console.error(message);
                              console.debug(error);
                              console.debug("get file error source " + error.source);
                              console.debug("get file error target " + error.target);
                          }
                      );
                  },
                  function (error) {
                      var message = "Unable to get file system. error: " + error.code;
                      document.getElementById("span").innerHTML = message;
                      console.error(message);
                      console.debug(error);
                      console.debug("file system error source " + error.source);
                      console.debug("file system error target " + error.target);
                  }
              );
          }
          &lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
          &lt;script type="text/javascript" src="cordova-2.5.0.js"&gt;&lt;/script&gt;
          &lt;button onclick="getPhoto(Camera.PictureSourceType.CAMERA, testResolveLocalFileSystemURI);"&gt;Capture Photo, Test Resolve Local File System URI&lt;/button&gt; &lt;br&gt;
          &lt;button onclick="getPhoto(Camera.PictureSourceType.CAMERA, testFileTransferUpload);"&gt;Capture Photo, Test File Transfer Upload&lt;/button&gt; &lt;br&gt;
          &lt;button onclick="getPhoto(Camera.PictureSourceType.CAMERA, testFileSystemGetFile);"&gt;Capture Photo, Test File System Get File&lt;/button&gt; &lt;br&gt;
          &lt;img style="display:none;" id="image" width="100" height="100" src="" /&gt;
          &lt;span id="span"&gt;&lt;/span&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Whenever I run the app and try to take a photo, I get:</p>
  
  <pre><code>Unable to resolve local file system URI...
  </code></pre>
  
  <p>Why can't either the FileTransfer or the window.resolveLocalFileSystemURI find the file that is returned from navigator.camera.getPicture? I have the standard config.xml from the phonegap example with all of the required features and permissions (at least as far as I know)</p>
  
  <p>Below is my config.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!-- 
         Licensed to the Apache Software Foundation (ASF) under one
         or more contributor license agreements.  See the NOTICE file
         distributed with this work for additional information
         regarding copyright ownership.  The ASF licenses this file
         to you under the Apache License, Version 2.0 (the
         "License"); you may not use this file except in compliance
         with the License.  You may obtain a copy of the License at
  
           http://www.apache.org/licenses/LICENSE-2.0
  
         Unless required by applicable law or agreed to in writing,
         software distributed under the License is distributed on an
         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
         KIND, either express or implied.  See the License for the
         specific language governing permissions and limitations
         under the License.
  --&gt;
  &lt;!--
    Widget Configuration Reference:
      http://docs.blackberry.com/en/developers/deliverables/15274/
  --&gt;
  
  &lt;widget xmlns="http://www.w3.org/ns/widgets"
          xmlns:rim="http://www.blackberry.com/ns/widgets"
      version="1.0.0.0" id="org.apache.cordova.example"&gt;
  
    &lt;name&gt;cordovaExample&lt;/name&gt;
  
    &lt;author&gt;Your Name Here&lt;/author&gt;
  
    &lt;description&gt;
         A sample Apache Cordova application that responds to the deviceready event.
    &lt;/description&gt;
  
    &lt;license href="http://opensource.org/licenses/alphabetical"&gt;
    &lt;/license&gt;
  
    &lt;!-- Cordova API --&gt;
    &lt;feature id="blackberry.system" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="org.apache.cordova" required="true" version="1.0.0" /&gt;
    &lt;feature id="blackberry.find" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="blackberry.identity" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="blackberry.identity.phone" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="blackberry.pim.Address" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="blackberry.io.file" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="blackberry.utils" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="blackberry.io.dir" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="blackberry.app" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="blackberry.app.event" required="true" version="1.0.0.0" /&gt;
    &lt;feature id="blackberry.system.event" required="true" version="1.0.0.0"/&gt;
    &lt;feature id="blackberry.widgetcache" required="true" version="1.0.0.0"/&gt;
    &lt;feature id="blackberry.media.camera" /&gt;
    &lt;feature id="blackberry.ui.dialog" /&gt;
    &lt;feature id="blackberry.connection" /&gt;
    &lt;feature id="blackberry.bbm.platform" /&gt;
    &lt;feature id="blackberry.invoke.card" /&gt;
    &lt;feature id="blackberry.pim.contacts" /&gt;
    &lt;feature id="blackberry.ui.contextmenu" /&gt;
    &lt;feature id="blackberry.io.filetransfer" /&gt;
    &lt;feature id="blackberry.io" /&gt;
    &lt;feature id="blackberry.invoke" /&gt;
    &lt;feature id="blackberry.invoked" /&gt;
    &lt;feature id="blackberry.push" /&gt;
    &lt;feature id="blackberry.media.microphone" required="true" version="1.0.0.0"/&gt;
  
    &lt;!-- Cordova API --&gt;
    &lt;access subdomains="true" uri="file:///store/home" /&gt;
    &lt;access subdomains="true" uri="file:///SDCard" /&gt;
    &lt;access subdomains="true" uri="file:///accounts" /&gt;
  
    &lt;!-- Expose access to all URIs, including the file and http protocols --&gt;
    &lt;access subdomains="true" uri="*" /&gt;
  
    &lt;icon rim:hover="false" src="res/icon/blackberry/icon-80.png" /&gt;
    &lt;icon rim:hover="true" src="res/icon/blackberry/icon-80.png" /&gt;
  
    &lt;rim:loadingScreen backgroundColor="#CFCFCF"
                       foregroundImage="res/screen/blackberry/screen-225.png"
               onFirstLaunch="true"&gt;
      &lt;rim:transitionEffect type="fadeOut" /&gt;
    &lt;/rim:loadingScreen&gt;
  
    &lt;content src="index.html" /&gt;
  
    &lt;rim:permissions&gt;
      &lt;rim:permit&gt;use_camera&lt;/rim:permit&gt;
      &lt;rim:permit&gt;read_device_identifying_information&lt;/rim:permit&gt;
      &lt;rim:permit&gt;access_shared&lt;/rim:permit&gt;
      &lt;rim:permit&gt;read_geolocation&lt;/rim:permit&gt;
      &lt;rim:permit&gt;record_audio&lt;/rim:permit&gt; 
      &lt;rim:permit&gt;access_pimdomain_contacts&lt;/rim:permit&gt; 
    &lt;/rim:permissions&gt;
  
  &lt;/widget&gt;
  </code></pre>
  
  <p>Below is my plugins.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!-- 
         Licensed to the Apache Software Foundation (ASF) under one
         or more contributor license agreements.  See the NOTICE file
         distributed with this work for additional information
         regarding copyright ownership.  The ASF licenses this file
         to you under the Apache License, Version 2.0 (the
         "License"); you may not use this file except in compliance
         with the License.  You may obtain a copy of the License at
  
           http://www.apache.org/licenses/LICENSE-2.0
  
         Unless required by applicable law or agreed to in writing,
         software distributed under the License is distributed on an
         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
         KIND, either express or implied.  See the License for the
         specific language governing permissions and limitations
         under the License.
  --&gt;
  &lt;plugins&gt;
    &lt;plugin name="App"            value="org.apache.cordova.app.App"/&gt;
    &lt;plugin name="Device"         value="org.apache.cordova.device.Device"/&gt;
    &lt;plugin name="Camera"         value="org.apache.cordova.camera.Camera"/&gt;
    &lt;plugin name="NetworkStatus"  value="org.apache.cordova.network.Network"/&gt;
    &lt;plugin name="Notification"   value="org.apache.cordova.notification.Notification"/&gt;
    &lt;plugin name="Accelerometer"  value="org.apache.cordova.accelerometer.Accelerometer"/&gt;
    &lt;plugin name="Geolocation"    value="org.apache.cordova.geolocation.Geolocation"/&gt;
    &lt;plugin name="File"           value="org.apache.cordova.file.FileManager"/&gt;
    &lt;plugin name="FileTransfer"   value="org.apache.cordova.http.FileTransfer"/&gt;
    &lt;plugin name="Contacts"       value="org.apache.cordova.pim.Contact"/&gt;
    &lt;plugin name="Capture"        value="org.apache.cordova.capture.MediaCapture"/&gt;
    &lt;plugin name="Battery"        value="org.apache.cordova.battery.Battery"/&gt;
    &lt;plugin name="Media"          value="org.apache.cordova.media.Media"/&gt;
    &lt;plugin name="Globalization"  value="org.apache.cordova.globalization.Globalization"/&gt;
  &lt;/plugins&gt;
  </code></pre>
  
  <p>Steps to reproduce my issue:</p>
  
  <ol>
  <li>Follow <a href="http://docs.phonegap.com/en/2.5.0/guide_getting-started_blackberry_index.md.html#Getting%20Started%20with%20BlackBerry" rel="nofollow">this</a> guide (using the BlackBerry 10(QNX) steps)</li>
  <li>replace the given index.html file with the one I provided</li>
  <li>replace the given config.xml file with the one I provided (changes should be minimal)</li>
  <li>debug it on a BB10 device (I am using a Z10)</li>
  <li>click the "capture photo" button, and if you have a remote web inspector connected, you should see the errors</li>
  </ol>