您好我无法复制iPhone手机上的官方本地目录。
我在这个函数copyFileToLocalDir
收到错误。
每当我从手机的图库和相机中获取图片时,我总会收到错误消息。在Android手机上的每张照片后,每张照片都在本地线上。我怎么才能得到它?
在 Android 手机上无缝工作时,为什么它适用于 iOS 手机?
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ı..');
});
}
答案 0 :(得分:0)
我有这个问题照片没有在ios中显示。这里的解决方案 加上这个:
import { normalizeURL } from 'ionic-angular';