Ich hole ein Bild anhand der URL und wandle es in Base64 um. Im Frontend füge ich dann nur noch "data:image/jpeg;base64," am Anfang ein.
Das Bild kann nicht angezeigt werden.
Wenn ich jedoch den unverschlüsselten String ( s ) zurückgebe, dann funktioniert es. Dazu verwende ich im Frontend die Javascript-Methode btoa.
www.w3schools.com
Java:
ResponseEntity<String> exchange = restTemplate.exchange(urlOfImage, HttpMethod.GET, entity, String.class);
String s = exchange.getBody();
String stringInBase64 = Base64.getEncoder().encodeToString(s.getBytes());
Wenn ich jedoch den unverschlüsselten String ( s ) zurückgebe, dann funktioniert es. Dazu verwende ich im Frontend die Javascript-Methode btoa.

W3Schools.com
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.