Pritish
Pritish

Reputation: 2224

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

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

enter image description here 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.

Upvotes: 2

Views: 4873

Answers (2)

Balaji
Balaji

Reputation: 10877

my case working only below syntax

cordova.file.externalRootDirectory

Below two syntax not working for me

already had(not working)

cordova.file.dataDirectory

above answare(not working)

cordova.file.externalDataDirectory

i am using capacitor version 2.0.0

Upvotes: 1

Homen
Homen

Reputation: 1212

You are using cordova.file.dataDirectory. In real device you can not access this folder using file manager/third party application. This is for security reason. If you want to see the downloaded file then use cordova.file.externalDataDirectory instead of cordova.file.dataDirectory . Then you can see the file inside application folder which is located inside internal memory.

Upvotes: 4

Related Questions