cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "siddharthc (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CB-11676) Apache Cordova File Does not Work with File Scanner Based on Cordova File Plugin on Marshmallow 6.0
Date Fri, 05 Aug 2016 21:52:20 GMT
siddharthc created CB-11676:
-------------------------------

             Summary: 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.5.0, 3.4.0
         Environment: Moto G3 Turbo : marshmallow 6.0 Does not work

Asus Zenfine 2 Android 5.0 Works as expected
            Reporter: siddharthc


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


Mime
View raw message