Adopt frontend to take in base64 images
This commit is contained in:
@@ -45,7 +45,7 @@ public class ImageController {
|
||||
return ResponseEntity.ok(images_base);
|
||||
}
|
||||
|
||||
@RequestMapping(path = IMAGE_BASE, method = RequestMethod.GET, produces = "image/*")
|
||||
@RequestMapping(path = IMAGE_BASE, method = RequestMethod.GET, produces = "text/plain")
|
||||
public ResponseEntity<String> getFirst(HttpServletRequest request,
|
||||
@RequestParam(value = PARAM_UUID) UUID uuid) {
|
||||
logRequest(request);
|
||||
|
||||
@@ -26,11 +26,12 @@ export default function ItemCard({ item }: { item: Item }) {
|
||||
useEffect(() => {
|
||||
const fetchImage = async () => {
|
||||
try {
|
||||
const response = await fetch(`http://localhost:8085/image?uuid=${item.uuid}`);
|
||||
const data = await response.json();
|
||||
if (data.uri) {
|
||||
setImageUrl(data.uri); // Bild-URL setzen
|
||||
const response = await fetch(`http://localhost:8085/image?uuid=${item.uuid}`); //image/* as base64
|
||||
const data = await response.text();
|
||||
if(data.length == 0) {
|
||||
console.error("Got emtpy picture for article ", item.uuid);
|
||||
}
|
||||
setImageUrl("data:image/jpeg;base64," + data);
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Laden des Bildes:", error);
|
||||
}
|
||||
|
||||
@@ -59,10 +59,11 @@ export default function ProductInfo({ item }: { item: Item }) {
|
||||
const fetchImage = async () => {
|
||||
try {
|
||||
const response = await fetch(`http://localhost:8085/image?uuid=${item.uuid}`);
|
||||
const data = await response.json();
|
||||
if (data.uri) {
|
||||
setImageUrl(data.uri); // Bild-URL setzen
|
||||
const data = await response.text();
|
||||
if(data.length == 0) {
|
||||
console.error("Got emtpy picture for article ", item.uuid);
|
||||
}
|
||||
setImageUrl("data:image/jpeg;base64," + data);
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Laden des Bildes:", error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user