Skip to content

Commit

Permalink
fix: changed the mimetype logic
Browse files Browse the repository at this point in the history
  • Loading branch information
harmbrugge committed Oct 15, 2024
1 parent e24a16f commit bc943ae
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import io.javalin.Javalin;
import io.javalin.http.Context;
import java.io.InputStream;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Path;

/**
* to allow for nice urls, and make it easier for 'schema' app developers we include the schema in
Expand Down Expand Up @@ -88,8 +89,7 @@ public static void addFileToContext(Context ctx, String path, String mimeType) {
return;
}
if (mimeType == null) {
ctx.req().getServletContext().getMimeType(path);
mimeType = URLConnection.guessContentTypeFromName(path);
mimeType = Files.probeContentType(Path.of(path));
if (mimeType == null) {
mimeType = "application/octet-stream";
}
Expand Down

0 comments on commit bc943ae

Please sign in to comment.