Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-11676

Apache Cordova File Does not Work with File Scanner Based on Cordova File Plugin on Marshmallow 6.0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 3.4.0, 3.5.0
    • None
    • cordova-android
    • Moto G3 Turbo : marshmallow 6.0 Does not work

      Asus Zenfine 2 Android 5.0 Works as expected

    Description

      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

      });

      Attachments

        Activity

          People

            Unassigned Unassigned
            siddmegadeth siddharthc
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: