2016-11-11 4 views
0

私は写真を手に入れています。私はそれらを見せたいと思うので、私のディレクトリに保存してください。私はこのフォーラムとw3cからの複合的な回答に続き、このコードを入手しました。私の問題は、私がfileSysディレクトリを取得したとき、onErrorに行き、myFolderAppディレクトリを取得できなくなったときです。 /storage/sdcard1/Android/data/tta.kirolapp.v1/filesエラー5写真をコルドバのアプリで撮るときにディレクトリを取得する

ディレクトリを確保するために失敗しました:: モニターは

は、ディレクトリを確保するために失敗しました」と表示します/storage/sdcard1/Android/data/tta.kirolapp.v1/files

これは正常ですオールトディレクトリがそう

/storage/emulated/0/0Android/data/tta.kirolapp.v1/

ですが、私はこれが問題だと思うが、私はそれを修正する方法がわかりません。 写真を撮影し、それを管理する機能のコード、次です:

function capturePhoto() { 
    alert('on capturePhoto'); 

    sessionStorage.removeItem('imagepath'); 
    //Cogemos la imagen y la codificamos en Base64 
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, cameraDirection: 1, saveToPhotoAlbum:true, destinationType: Camera.DestinationType.FILE_URI }); 
} 

function onPhotoDataSuccess(imageURI) { 
     // Uncomment to view the base64 encoded image data 
     // console.log(imageData); 

     // Get image handle 
     // 
     var imgProfile = document.getElementById('fotoRegistro'); 

     // Pasamos la imagen a pantalla desde imageURI 
     // 
     console.log('El url por defecto es: '+ imageURI); 
     imgProfile.src = imageURI; 
     if(sessionStorage.isprofileimage==1){ 
      getLocation(); 
     } 
     movePic(imageURI); 
} 

// Funcion onError 
// 
function onFail(message) { 
    alert('Failed because: ' + message); 
} 

function movePic(file){ 
    window.resolveLocalFileSystemURL(file, resolveOnSuccess, resOnError); 
} 

//Callback function when the file system uri has been resolved 
function resolveOnSuccess(entry){ 
    console.log("Estoy en resolveOnSuccess"); 
    var d = new Date(); 
    var n = d.getTime(); 
    //new file name 
    var identificacion= $('#idEmailReg').val(); 
    var newFileName="foto"+identificacion+".jpg"; 
    console.log ('El newFileName es: '+ newFileName); 
    var myFolderApp = "file:///storage/emulated/0/Android/data/tta.kirolapp.v1/img/"; 
     //appConstants.localPermanentStorageFolderImg; 
    console.log ('El nuevo directorio es: '+ myFolderApp); 
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {  
    console.log ('Entramos en el request onSuccess'); 
    //The folder is created if doesn't exist 
    fileSys.root.getDirectory(myFolderApp, 
        {create:true, exclusive: false}, 
        function(directory) { 
         console.log('El directory es: '+ directory); 
         entry.moveTo(directory, newFileName, successMove, resOnError); 
        }, 
        resOnError); 
        }, 
    resOnError); 
} 

//Callback function when the file has been moved successfully - inserting the complete path 
function successMove(entry) { 
    //Store imagepath in session for future use 
    // like to store it in database 

    sessionStorage.setItem('imagepath', entry.fullPath); 
} 

function resOnError(error) { 
    alert(error.code); 
} 

resOnErrorコード「5」を示しており、モニタ出力は次です: enter image description here

答えて

0

私はメディアを使用私objects.jsファイルで

function capturePhoto(){ 
    //var fileFolder="/storage/emulated/0/KirolApp/img/"; 
    var fileFolder=appConstants.localPermanentStorageFolderImg(); 
    var identificacion= $('#idEmailReg').val(); 
    var fileName="foto"+identificacion+".jpg"; 
    photo.takeAsync(
     fileFolder, 
     fileName, 
     function() { 
      console.log('En capturePhoto funcion'); 
      var urlCompleta=photo.fileFolder+photo.fileName; 
      console.log('URL Completa: '+ urlCompleta); 

      $("#fotoRegistro").attr("src","file://"+urlCompleta+"?"+(new Date()).getTime()); 
     } 
    ); 
} 

プラグインと写真の取り込みで写真を撮る、これはコードです10

そしてfileUtilities:UPV/EHUからM.HとG.Pに

var fileUtilities = { 
     moveAsync: function (sourceFullPath,destFolder,destName,onSuccess){ 
      var url="file://"+sourceFullPath; 
      var destFile=destFolder+destName; 
      var ft=new FileTransfer(); 
      ft.download(url,destFile, 
       function() { 
        window.resolveLocalFileSystemURL(url, 
          function(fileEntry) { 
         fileEntry.remove(onSuccess); 
          }, 
          function(error) { 
           alert("Source file NOT accesible; not removed"); 
          } 
        );   
       }, 
       function(error) { 
        alert('File not copied. '+'error.code: '+error.code+'\nerror.source: '+error.source+'\nerror.target: '+error.target+'\nerror.http_status: '+error.http_status); 
       } 
      ); 
     } 
}; 

感謝。

関連する問題