Publicar archivo de imagen a eventos que no funcionan en Ionic 3
Estoy trabajando en la aplicación Ionic y he realizado la funcionalidad de actualización de la imagen del perfil en mi aplicación y está funcionando bien, pero cuando trato de actualizar la imagen del perfil del usuario no está enviando la ruta correcta de la imagen.
Este es mi 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);
}
}
});
}
});
}
En mi archivo ts, envío la imagen a mi app.html para mostrar la imagen actualizada con este código:this.events.publish('userprofile:created', this.selectedImage);
pero el problema es que no está enviando la URL de imagen adecuada que está enviando como un archivo [objeto].
Para referencia:https: //stackblitz.com/edit/ionic-ydpha
Cuando envío la imagen a about.ts, muestra el error.
Cualquier ayuda es muy apreciada