mashrurbd opened a new issue #435:
URL: https://github.com/apache/cordova-plugin-file/issues/435


   # Bug Report
   The file path is returning undefined.
   ## Problem
   I am checking for images in externalRootDirectory. But the problem is the 
returned JSON gets undefined. Please help me resolving this issue.
   ### What is expected to happen?
   A json is expected to return like: 
   `{'found':true, 'img_url':'/path/to/file'}'`
   
   
   ### What does actually happen?
   
   The json object returning undefined.
   
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
   ```
   function ibx_check_image(path,device_folder)
   {
       
       
window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory,function 
(rootDirEntry) {
           rootDirEntry.getDirectory('SnapTook', { create: true }, function 
(dirEntry) {
               dirEntry.getDirectory(''+device_folder+'', { create: true }, 
function (subDirEntry) {
                   subDirEntry.getFile(''+path+'', { create: false, exclusive: 
true }, function (fileEntry) {
                       var found = true;
                       var ib_img_url = fileEntry.fullPath;
                       // This returns undefined 
                       return {found, ib_img_url}
   
   
                       
                   }, function(err)
                   {
                       // alert('File not found babe!');
                        var found = false;
                       var ib_img_url = 'none';
                       // This returns undefined 
                       return {found, ib_img_url}                
                   });
               }, onErrorGetDir);
           }, onErrorGetDir);
           
   
       }, getFSFail);
   
   
       
   
   }
   ```
   
   When I call the function like this, the function returns the JSON as 
undefined.
   
   ```
   var opfile = ibx_check_image('my_image.jpg','Images');
   
   console.log(opfile) // undefined
   ```
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   
   Android, JavaScript
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   
   Cordova CLI
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to