Ionic 4 Transforming base64Image to something shorter and showing it

All this is local since its all tests for now, in the future I’ll keep the things on cloud.

What I’m trying to do right now is:

  • have user’s image being displayed on the menu
  • when he clicks it he can choose an image from his gallery
  • set that image as his profile picture
    I do all this by using the Camera and CameraOptions, but when I do this I get a base64image which is like 300kb each, which I keep on the database as the user’s image reference, but that’s insanely big to be a reference, specially since there’ll be many users, so I need that reference to be wayyyyy smaller, I found a way to do so

just in case its needed, this is how I get the image and set it as his profile picture, works fine
but as u can see at the end I send the image to yet another method I have, well I wanted that method to create a smaller link for the image and then there set it as a profile picture instead with that smaller link, but since it’s not working, for now I’m setting the avatar with the base64 reference

Here is the method that’s supposed to convert it

And appearently it really does, the dataUrl really ends up being exactly what I’d hope for

BUT, thing is, setting the image with the new smaller link isn’t working

This is how it’s displayed on html

how come does it work with the longer reference but not with the shorter one


Maybe the kind of link I’m generating isnt correct, or the way I’m using it isn’t correct
All i wanted was to NOT keep that +300 kb reference of the image on the database, I wanted something shorter