File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
java/src/main/java/com/genexus Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change 77import java .awt .image .BufferedImage ;
88import java .io .*;
99import java .net .URL ;
10+ import java .net .URLConnection ;
1011
1112import com .genexus .db .driver .ResourceAccessControlList ;
1213import com .genexus .util .GxFileInfoSourceType ;
@@ -49,13 +50,10 @@ public static long getFileSize(String imageFile){
4950 IHttpContext httpContext = com .genexus .ModelContext .getModelContext ().getHttpContext ();
5051 if (imageFile .toLowerCase ().startsWith ("http://" ) || imageFile .toLowerCase ().startsWith ("https://" ) ||
5152 (httpContext .isHttpContextWeb () && imageFile .startsWith (httpContext .getContextPath ()))){
52- try (ByteArrayOutputStream baos = new ByteArrayOutputStream ()) {
53- BufferedImage image = ImageIO .read (new URL (GXDbFile .pathToUrl ( imageFile , httpContext )).openStream ());
54- String extension = imageFile .substring (imageFile .lastIndexOf ("." ) + 1 );
55- ImageIO .write (image , extension , baos );
56- baos .flush ();
57- byte [] imageInByte = baos .toByteArray ();
58- return imageInByte .length ;
53+ try {
54+ URL url = new URL (imageFile );
55+ URLConnection connection = url .openConnection ();
56+ return Long .parseLong (connection .getHeaderField ("Content-Length" ));
5957 } catch (Exception e ) {
6058 log .error ("getFileSize " + imageFile + " failed" , e );
6159 }
You can’t perform that action at this time.
0 commit comments