Correct servlet handling behavior for png resource
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
index f6f0ef9..b1f5cd3 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
@@ -10,12 +10,14 @@
import java.io.FileInputStream;
import java.util.List;
import java.util.logging.Level;
+import java.awt.image.BufferedImage;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.activation.MimetypesFileTypeMap;
+import javax.imageio.ImageIO;
import edu.uci.ics.asterix.api.common.APIFramework.DisplayFormat;
import edu.uci.ics.asterix.api.common.SessionConfig;
@@ -127,26 +129,14 @@
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
-
+
+ // Special handler for font files and .png resources
if (resourcePath.endsWith(".png")) {
- // Handle PNG content for webui
- response.setContentType(new MimetypesFileTypeMap().getContentType(resourcePath));
-
- // Read image file size
- File pngFile = new File(resourcePath);
- response.setContentLength((int)pngFile.length());
-
- // Initialize filestreams, and write to output
- OutputStream pngOut = response.getOutputStream();
-
- byte[] buf = new byte[1024];
- int len;
- while ((len = is.read(buf)) >= 0) {
- pngOut.write(buf, 0, len);
- }
-
- // Close streams
- pngOut.close();
+ BufferedImage img = ImageIO.read(is);
+ OutputStream outputStream = response.getOutputStream();
+ ImageIO.write(img, "png", outputStream);
+ outputStream.close();
+ response.setContentType("image/png");
return;
}
diff --git a/asterix-app/src/main/resources/webui/querytemplate.html b/asterix-app/src/main/resources/webui/querytemplate.html
index 3441ce2..e122e0e 100644
--- a/asterix-app/src/main/resources/webui/querytemplate.html
+++ b/asterix-app/src/main/resources/webui/querytemplate.html
@@ -121,8 +121,7 @@
</a>
<!-- Temporary logo placeholder -->
- <!-- <a class="brand" href="#"><img src="/webui/static/img/finalasterixlogo.png"></a> -->
- <a class="brand" href="#"><img src="http://db.tt/J1MTCdKs"></a>
+ <a class="brand" href="#"><img src="/webui/static/img/finalasterixlogo.png"></a>
<div class="nav-collapse collapse">
<ul class="nav">