server responds with proper content types
This commit is contained in:
parent
347b64cbc8
commit
2ae3d83e97
1 changed files with 9 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue