2017-02-06 3 views
1

Ich habe eine mobile App (mit ionic/cordova) erstellt, die eine mp4-Datei herunterlädt. Ich habe es in Android gemacht, aber kein Glück in iOS. Sonderbare Sache ist, dass es manchmal funktioniert, manchmal nicht (nur in iOS). Ich habe das Plugin cordova-plugin-file-transfer verwendet, wenn es funktioniert, es funktioniert perfekt. Aber wenn ich den Fehler aufmerksam machen, erhalte ich folgende:

kann nicht Pfad erstellen heruntergeladene Datei zu speichern: Sie stehen ganz keine Berechtigung, die Datei
Fehlercode zu speichern: 1

hier ist mein Code ein:

$scope.download = function(){ 

     var downloadProgress =''; 
     var url = "http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_5mb.mp4"; 
     var MyFiles = cordova.file.dataDirectory + 'test1.mp4'; 
     $cordovaFileTransfer.download(url,MyFiles,{}, true).then(
      function(result){//success download 

       $ionicLoading.hide(); 
       var alertPopup = $ionicPopup.alert({ 
        title: 'Download Successful!', 
       }); 


      }, function(error){ 
        var alertPopup = $ionicPopup.alert({ 
             title: 'Error', 
             template: JSON.stringify(error) 
            }); 
      }, function(progress){ 
          $timeout(function() { 
           downloadProgress = (progress.loaded/progress.total) * 100; 
          }); 

          $ionicLoading.show({ 
           template: 'Download in progress please wait<br/><progress id="progressbar" max="100" value="'+ downloadProgress +'"> </progress>' + 
           '<div id="progressbarlabel">' + Math.ceil(downloadProgress) + '%</div>' 
            }); 
       }); 

    } 
+0

kann Gebrauch cordova.file.externalRootDirectory sein, dass der Ort, um die Bilder im Gerät –

+0

nah zu speichern ich bereits alle das Verzeichnis verwendet –

Antwort

0

ich habe versucht, mit cordova.file.documentsDirectory in iOS dies:

Und das Ergebnis im Emulator war sehr gut, aber wenn ich in einem realen Gerät versucht, erhalte ich:

Sie haben keine Berechtigung, die Datei „Documents“ im Ordner „speichern MY- APP-ID-XXXXXX ".

so habe ich versucht, mit cordova.file.dataDirectory:

if (ionic.Platform.isIPad() || ionic.Platform.isIOS()) { 
      console.log("Is iPad or iOS"); 
      $rootScope.TARGETPATH = cordova.file.dataDirectory;; 
     }