You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Kerri Shotts (JIRA)" <ji...@apache.org> on 2016/08/06 20:15:20 UTC

[jira] [Commented] (CB-11676) Apache Cordova File Does not Work with File Scanner Based on Cordova File Plugin on Marshmallow 6.0

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

Kerri Shotts commented on CB-11676:
-----------------------------------

Thoughts:

- Why are you wrapping "cordova.file.dataDirectory" in quotes? I wouldn't ever expect that to work with the file plugin's URI resolution methods. Pass it without quotes and see if the behavior improves.

- Please post a link to a sample app that duplicates the failures you are seeing so we can easily duplicate the issue.

- Please verify which version(s) of the File Plugin you are using. If you aren't using the latest, try upgrading to see if that helps.

- Please verify which version(s) of cordova-android you are using. If you aren't using the latest, try upgrading to see if that helps.

> Apache Cordova File Does not Work with File Scanner Based on Cordova File Plugin on Marshmallow 6.0
> ---------------------------------------------------------------------------------------------------
>
>                 Key: CB-11676
>                 URL: https://issues.apache.org/jira/browse/CB-11676
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 3.4.0, 3.5.0
>         Environment: Moto G3 Turbo : marshmallow 6.0 Does not work
> Asus Zenfine 2 Android 5.0 Works as expected
>            Reporter: siddharthc
>              Labels: github-import
>
> this is a open source project on Github 
> https://github.com/siddmegadeth/cordova-file-scanner
> he goal is to provide a set of API to traverse,search any kind of file on ANdroid system based on file type.
> The File Plugin API returns
> fileError Code 5
> This is not replicated on 5.0 on Zenfone
> Moto G3 Turbo : marshmallow 6.0 Does not work  
> Asus Zenfine 2 Android 5.0 Works as expected
> API USAGE :
>  var url = [
>               "cordova.file.dataDirectory",
>               "cordova.file.documentsDirectory",
>               "cordova.file.externalApplicationStorageDirectory",
>               "cordova.file.externalCacheDirectory",
>               "cordova.file.externalRootDirectory",
>               "cordova.file.sharedDirectory",
>               "cordova.file.syncedDataDirectory",
>               "cordova.file.applicationStorageDirectory",
>               "cordova.file.cacheDirectory",
>               "cordova.file.applicationDirectory",
>               "cordova.file.tempDirectory",
>               "cordova.file.rootDirectory"
>             ];
>       fileType = ["mp3","mp4","avi","pdf"];
>       cordovaFile.scan(url,fileType,function(resp)
>       {
>         $rootScope.response = resp;
>       },function(error)
>       {
>         log(error);
>       });
> API DETAIL DESCRIPTION
> var file  =  angular.module("CordovaFileReader",[]);
> file.service("cordovaFile",function($q,$timeout)
> {
>   var list = [];
>   //var deferred = $q.defer();
>  // var promises = [deferred.promise];
>   return {
>     scan : function(url,fileType,success,failure)
>     {
>       var i=0;
>       while(i!=fileType.length)
>       {
>         list[fileType[i]] = [];
>         i+=1;
>       }
>        // list[fileType[0]] = [];
>        // list[fileType[1]] = [];
>        //Get List Of FilesType and Create named associativr Array
>       //Function Definition For fileEntry and Error
>       var fileSearch = function (entry) {
>    
>       
>       var dirReader = entry.createReader();
>       dirReader.readEntries(
>           function (entries) {
>               var i=0;
>               while(i!=entries.length) 
>               {
>                   if (entries[i].isDirectory === true) {
>                       // Recursive -- call back into this subdirectory
>             
>                       fileSearch(entries[i]);
>                   } else 
>                   {
>         
>                     var j=0;
>                     while(j!=fileType.length)
>                     {
>                       if(entries[i].name.indexOf(fileType[j]) != -1)
>                       {
>                       
>                       var file = {};
>                       file = entries[i];
>                       file.type = fileType[j];
>                       
>                      list[fileType[j]].push(file);
>                       }
>                     j+=1;
>                     }
>                  //    if(entries[i].name.indexOf(fileType[0]) != -1)
>                  //    {
>                       
>                  //      var file = {};
>                  //      file = entries[i];
>                  //      file.type = fileType[0];
>                       
>                  //     list[fileType[0]].push(file);
>                  //   //   promises.push(file);
>                  // //     console.log(file);
>                  //    }
>                  //    else if(entries[i].name.indexOf(fileType[1]) != -1)
>                  //    {
>                       
>                  //      var file = {};
>                  //      file = entries[i];
>                  //      file.type = fileType[1];
>                  //      list[fileType[1]].push(file);
>                  //    //  console.log(file);
>                  //     //    promises.push(file);
>                  //    }
>                   }
>                   i+=1;
>               }
>              // Return List As CurrentSearch File and ll Files Searched in globalLis
>              // deferred.resolve();
>               
>            success(list);  
>           },
>           function (error) 
>           {
>               console.log(error);
>             //  deferred.reject(list);
>             failure(error);
>           });
>       //  return $q.all(promises);
>     };   //Func ENds
>    
>      var i=0;
>      while(i!=url.length) 
>      {
>         if (url[i] === null || url[i].length === 0) 
>         {
>             continue; // skip blank / non-existent paths for this platform
>         }
>         window.resolveLocalFileSystemURL(url[i],fileSearch, function (error) {
>           console.log(error);
>           failure(error);
>         });
>         i+=1;
>       }
>     }  //scan Ends
>   };  /// return Ends
> });



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org