cordova.file.dataDirectory not creating file inside the app folder


#1

Downloading images using cordova.file into dataDirectory. I am saving files into internal app folder. In the emulator I am able to see the downloaded files but on real device I am not able to see the downloaded file. This is my path look like

not able to see this image into app folder.

$scope.Download = function () {
            var FileURL = appService.downloadFiles($scope.selectedFile.FileKey);
            var targetPath = cordova.file.dataDirectory + "ChatApp/" + $scope.selectedFile.FileName;
            var trustHosts = true;
            var options = {};
            $cordovaFileTransfer.download(FileURL, targetPath, options, trustHosts)
                  .then(function (result) {
                      alert('file downloaded successfully');
                      console.log(result);
                      refreshMedia.refresh(targetPath);
                  }, function (err) {                      
                      console.log(err);
                  }, function (progress) {
                      console.log(progress);                      
                  });

        };       
    }

Does it required any permission to create folder inside cordova.file.dataDirectory. How I see this file inside the internal app folder.


#2

Do you get any error message? Does the permission resolve or reject? Does “ChatApp/” exist?

Do you have more or less this lines in your config.xml file?

<allow-navigation href="*"/>
<allow-navigation href="http://*/*"/>
<allow-navigation href="file://*/*"/>
<allow-intent href="*"/>
<access origin="*"/>

Do you have this array in the json of your ionic.project file (only needed, if you get your download path by an html response)?

 "proxies": [
    {
      "path": "/api",
      "proxyUrl": "https://www.mydomain.com/api"
    }
  ], ...

Tell me … TELL ME :wink:


#3

In my config file

  <allow-navigation href="*"/>
<allow-navigation href="http://*/*"/>
<allow-intent href="*"/>
<access origin="*"/>

also similar setting in ionic.project file

only <allow-navigation href="file://*/*"/> this setting is not available


#4

Then write it in your config.xml and you’ll be able to access it locally. Or is the whole file missing? Did the permission resolve or reject?

Did it help?