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

$cordovaFileTransfer.download returns "null" always

    XMLWordPrintableJSON

Details

    Description

      When I use the next code I always get this error:

      ERROR:

      {"code":null,"source":null,"target":null,"http_status":null,"body":null,"exception":null}
      

      CODE:

               var url = "http://foo.bar/img/image.png";
               var filename = url.split("/").pop();
               var targetPath = cordova.file.externalRootDirectory + 'Pictures/' + filename;
      
      
               console.log(filename); // returns "image.png"
               console.log(targetPath); // returns "file:///storage/emulated/0/Pictures/image.png"
      
                  $cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result) {
                        console.log(JSON.stringify(result));
                        $scope.hasil = 'Save file on '+targetPath+' success!';
                        $scope.mywallpaper=targetPath;
                  }, function (error) {
      /* return {"code":null,"source":null,"target":null,"http_status":null,"body":null,"exception":null}*/
                        console.log(JSON.stringify(error));
                        $scope.hasil = 'Error Download file';
                  }, function (progress) {
                        $scope.downloadProgress = (progress.loaded / progress.total) * 100;
                  });
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            joanebrown joanebrown
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: