Publishing arquivo de imagem para eventos que não funcionam no Ionic 3
Estou trabalhando no Ionic App e fiz a funcionalidade de atualização da imagem do perfil no meu aplicativo e está funcionando bem, mas quando tento atualizar a imagem do perfil do usuário, ele não está enviando o caminho correto da image
Este é meu updateimage.ts:
onImageSelected(event) {
this.selectedImage = event.target.files[0];
let reader = new FileReader();
reader.onload = (e: any) => {
this.imageUrl = e.target.result;
this.converted_image = "data:image/jpeg;base64,"+this.imageUrl;
};
reader.readAsDataURL(this.selectedImage);
}
changeProfileImage()
{
this.storage.get("ID").then((val) =>
{
if(val)
{
var fd = new FormData();
fd.append('upic', this.selectedImage, this.selectedImage.name);
fd.append('user_id', val);
this.restProvider.updateprofileimg(fd, 'update_profilepic/'+val).subscribe((data) => {
if (data) {
this.responseEdit = data;
if (this.responseEdit.status === 'success') {
this.events.publish('userprofile:created', this.selectedImage); <!-- I am sending the image to the app.html -->
this.presentAlert(this.responseEdit.msg);
}
}
});
}
});
}
No meu arquivo ts, estou enviando a imagem para o meu app.html, mostrando a imagem atualizada usando este código:this.events.publish('userprofile:created', this.selectedImage);
mas o problema é que ele não está enviando a URL da imagem correta como um arquivo [objeto].
Para referência:https: //stackblitz.com/edit/ionic-ydpha
Quando estou enviando a imagem para o about.ts, está mostrando o err
Qualquer ajuda é muito apreciada