0
嗨我不能複製iPhone手機上的官方本地目錄。 我在此功能copyFileToLocalDir
處收到錯誤消息。 每當我從手機的相冊和相機中獲取圖片時,我總是會收到錯誤消息。在android手機上的每張照片後,每張照片都在本地線上。我怎麼才能得到它? 爲什麼它能在上工作iOS手機在無縫工作時Android手機?離子2圖像本地目錄複製不起作用
presentActionSheet(){
let actionSheet = this.actionSheetCtrl.create({
title : "Resim Kaynağını Seçiniz",
buttons : [{
text : "Galeriden Seç",
handler :()=>{
this.takePicture(this.camera.PictureSourceType.PHOTOLIBRARY);
}
},{
text : "Resim Çek",
handler :()=>{
this.takePicture(this.camera.PictureSourceType.CAMERA);
}
}]
});
actionSheet.present();
}
takePicture(SOURCETYPE){
var options = {
quality : 25,
sourceType : SOURCETYPE,
destinationType : this.camera.DestinationType.FILE_URI,
encodingType : this.camera.EncodingType.JPEG,
saveToPhotoAlbum : false,
correctOrientation : true
};
var yerelDizinAndroid;
var yerelDizinIOS;
this.camera.getPicture(options).then((imagePath)=>{
if(this.platform.is('android') && SOURCETYPE === this.camera.PictureSourceType.PHOTOLIBRARY){
this.filePath.resolveNativePath(imagePath).then(filePath =>{
let correctPath = filePath.substr(0, filePath.lastIndexOf('/') + 1);
let currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('?'));
yerelDizinAndroid = currentName;
this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
});
}else {
var currentName = imagePath.substr(imagePath.lastIndexOf('/') + 1);
var correctPath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1);
yerelDizinIOS = currentName;
this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
}
}, (err) => {
this.presentToast('Herhangi bir işlem yapılmadı.');
/* this.file.removeDir(cordova.file.dataDirectory, yerelDizinAndroid);
this.file.removeDir(cordova.file.dataDirectory, yerelDizinIOS); */
});
}
private createFileName() {
var newFileName = "S" + window.localStorage.getItem("auth_key") + ".jpg";
return newFileName;
}
private copyFileToLocalDir(namePath, currentName, newFileName) {
this.file.copyFile(namePath, currentName, cordova.file.dataDirectory, newFileName).then(success => {
this.lastImage = newFileName;
}, (error) => {
this.presentToast('Görsel yerel dizine taşınamadı..');
});
}
什麼是你所得到的特定的錯誤?而要清楚的是,它適用於Android,但不適用於iOS? – lintmouse
是的,它不適用於iOS手機@lintmouse – Degisim
如果它在一個平臺上運行,但不在另一個平臺上,那麼它可能是特定平臺上的限制/訪問權限。確保您使用的是正確的文件路徑。我不認爲這是離子框架相關的,更像是OS/Cordova相關的。 – DanteTheSmith