diff --git a/java/src/main/java/com/genexus/GxImageUtil.java b/java/src/main/java/com/genexus/GxImageUtil.java index d3904ed3f..9c831a32e 100644 --- a/java/src/main/java/com/genexus/GxImageUtil.java +++ b/java/src/main/java/com/genexus/GxImageUtil.java @@ -7,6 +7,7 @@ import java.awt.image.BufferedImage; import java.io.*; import java.net.URL; +import java.net.URLConnection; import com.genexus.db.driver.ResourceAccessControlList; import com.genexus.util.GxFileInfoSourceType; @@ -49,13 +50,10 @@ public static long getFileSize(String imageFile){ IHttpContext httpContext = com.genexus.ModelContext.getModelContext().getHttpContext(); if (imageFile.toLowerCase().startsWith("http://") || imageFile.toLowerCase().startsWith("https://") || (httpContext.isHttpContextWeb() && imageFile.startsWith(httpContext.getContextPath()))){ - try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { - BufferedImage image = ImageIO.read(new URL(GXDbFile.pathToUrl( imageFile, httpContext)).openStream()); - String extension = imageFile.substring(imageFile.lastIndexOf(".") + 1); - ImageIO.write(image, extension, baos); - baos.flush(); - byte[] imageInByte = baos.toByteArray(); - return imageInByte.length; + try { + URL url = new URL(imageFile); + URLConnection connection = url.openConnection(); + return Long.parseLong(connection.getHeaderField("Content-Length")); } catch (Exception e) { log.error("getFileSize " + imageFile + " failed" , e); }