79609054

Date: 2025-05-06 15:52:15
Score: 0.5
Natty:
Report link

Okey finally i got it,The external app already encode to img to bytes but in the backend i created the variable image like a byte[] instead of a String this made that the image chain were encoding again. The solution was refactor the variable image to a String and in the frontend get sanitize the img to get his mime type with this function:

  sanitizeBase64Image(imageData: string): string {
if (!imageData) {
  return 'assets/default-product.jpg'; 
}

const mimeType = imageData.startsWith('iVBOR') ? 'image/png' : 
                 imageData.startsWith('/9j/') ? 'image/jpeg' : 
                 //Add more conditions for other image types if needed
                 'image/octet-stream';  

return `data:${mimeType};base64,${imageData}`; 

}

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: CrismaiX