I'm using https://www.npmjs.com/package/ngx-image-cropper to crop images uploaded from angular to my api in node, the problem is that it transforms them to base64 and although everything is fine, I can't upload them like this server so I'm trying to convert them to type File
let nuevo = new FormData();
let split = this.croppedImage.split(",")[1];
let blob = new Blob([atob(split)], { type: "image/png" });
let file = new File([blob], "imageFileName.png");
nuevo.append("tipo", "perfil");
nuevo.append("user", this.id.toString());
nuevo.append("image", file);
this.dataService.nuevaImage(nuevo).subscribe(
res => console.log(res),
err => console.log(err)
)
until the moment of using the split everything is ok, but when transforming it to File and sending it to the api it looks black and in local it says that the format is not compatible. PS: The api does not throw an error
I was able to fix it with https://stackblitz.com/edit/ngx-image-croppe-anartz?fbclid=IwAR2caX0Kd1IkZ9e_2vBlUm9hTXCUCb5BZtlezwAtwEMl_YcKaaFj472bVGE
the issue of decoding is a bit cumbersome but this helped me