From 3e3d79165786edfdff2ca26d3ffb09172624f435 Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 20 May 2019 18:27:49 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-594=20mime=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/ui/Assistant.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/ui/Assistant.java b/designer-base/src/main/java/com/fr/design/ui/Assistant.java index f15d4164f0..3962692c73 100644 --- a/designer-base/src/main/java/com/fr/design/ui/Assistant.java +++ b/designer-base/src/main/java/com/fr/design/ui/Assistant.java @@ -6,8 +6,14 @@ import com.teamdev.jxbrowser.chromium.BrowserContext; import com.teamdev.jxbrowser.chromium.ProtocolService; import com.teamdev.jxbrowser.chromium.URLResponse; +import javax.activation.MimetypesFileTypeMap; import java.io.DataInputStream; +import java.io.File; +import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; /** * @author richie @@ -44,7 +50,12 @@ public class Assistant { if (path.endsWith(".svg")) { return "image/svg+xml"; } - return "text/html"; + Path file = new File(path).toPath(); + try { + return Files.probeContentType(file); + } catch (IOException e) { + return "text/html"; + } } public static void setEmbProtocolHandler(Browser browser, EmbProtocolHandler handler) {