server responds with proper content types

This commit is contained in:
1e99 2024-12-16 15:55:04 +01:00
parent 347b64cbc8
commit 2ae3d83e97

View file

@ -1,6 +1,7 @@
package eu.e99.pixelchat.server;
import eu.e99.pixelchat.server.storage.Storage;
import io.javalin.http.ContentType;
import io.javalin.http.Context;
import io.javalin.http.HttpStatus;
import org.apache.commons.imaging.ImageFormats;
@ -35,7 +36,10 @@ public class ImageHandler {
String id = storage.put(png, expiresAt);
logger.info("Stored {} bytes as {}", png.length, id);
ctx.status(HttpStatus.CREATED).result(id);
ctx.
status(HttpStatus.CREATED).
contentType(ContentType.TEXT_PLAIN).
result(id);
}
public void downloadImage(Context ctx) throws IOException {
@ -46,6 +50,9 @@ public class ImageHandler {
return;
}
ctx.status(HttpStatus.OK).result(png);
ctx.
status(HttpStatus.OK).
contentType(ContentType.IMAGE_PNG).
result(png);
}
}