У меня возникают проблемы при отображении файла изображения из каталога кэша моего ионного приложения .. Мой процесс работает следующим образом:
1) Он копирует файл из памяти телефона в каталог кэша (функция копирования работаетхорошо (я получаю запись взамен)
copyFile(uriFile,targetPath,newName){
var deferred = new Promise<any>(resolve => {
this.file.resolveLocalFilesystemUrl(uriFile).then(fileEntry =>
{
this.filePath.resolveNativePath(fileEntry.nativeURL).then(
filePath =>
{
if(newName == null)
newName = filePath.split('/').pop();
else if(newName == "")
newName = filePath.split('/').pop();
this.file.resolveDirectoryUrl(targetPath).then(dirEntry => {
fileEntry.copyTo(dirEntry,newName, entry =>{
resolve(entry);
}, function(error){
resolve("ERROR");
});
});
},
error => {
resolve("ERROR");
});
})
.catch(error => {
resolve("ERROR");
})
});
2) Далее Он устанавливает атрибут objet с entry.nativeURL
getRepertoireTemporaire()
{
if(this.rootScope.mobileType == "IOS")
return this.file.tempDirectory;
else
return this.file.cacheDirectory;
}
var uriFile = "";
if(this.rootScope.mobileType == "IOS")
uriFile = this.file.syncedDataDirectory;
else
uriFile = this.file.externalRootDirectory;
uriFile += fileName;
this.techniqueMetier.copyFile(uriFile, this.techniqueMetier.getRepertoireTemporaire(),null).then(entry =>
{
this.info.path = entry.nativeURL;
if(name != "ERROR")
this.info.displayImage = true;
else
this.info.displayImage = false;
this.content.scrollToBottom(500);
}).catch(err =>
{
alert(err);
});
3) И я отображаю файл в моем представлении как:
<img *ngIf="info.displayImage" style="width: 100%;" [src]="info.path">
Я использую cordova-plugin-ionic-webview Может быть, это такпотому что я - предыдущая версия моего приложения (ionic v1), этот процесс работал = (
Кто-то знает, пожалуйста? С уважением