File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
common/src/main/java/com/genexus
java/src/main/java/com/genexus Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -63,5 +63,5 @@ public interface IHttpContext {
6363 boolean isHttpContextNull ();
6464 boolean isHttpContextWeb ();
6565
66-
66+ String getContextPath ();
6767}
Original file line number Diff line number Diff line change 66import java .awt .image .AffineTransformOp ;
77import java .awt .image .BufferedImage ;
88import java .io .*;
9+ import java .net .URL ;
910
1011import com .genexus .db .driver .ResourceAccessControlList ;
1112import com .genexus .util .GxFileInfoSourceType ;
@@ -22,13 +23,19 @@ private static InputStream getInputStream(String filePathOrUrl) throws IOExcepti
2223
2324 private static BufferedImage createBufferedImageFromURI (String filePathOrUrl ) throws IOException
2425 {
25- try (InputStream is = getGXFile (filePathOrUrl ).getStream ()) {
26+ IHttpContext httpContext = com .genexus .ModelContext .getModelContext ().getHttpContext ();
27+ InputStream is = null ;
28+ try {
29+ if (filePathOrUrl .toLowerCase ().startsWith ("http://" ) || filePathOrUrl .toLowerCase ().startsWith ("https://" ) ||
30+ (httpContext .isHttpContextWeb () && filePathOrUrl .startsWith (httpContext .getContextPath ())))
31+ is = new URL (GXDbFile .pathToUrl ( filePathOrUrl , httpContext )).openStream ();
32+ else
33+ is = getGXFile (filePathOrUrl ).getStream ();
2634 return ImageIO .read (is );
27- }
28- catch (IOException e ) {
35+ } catch (IOException e ) {
2936 log .error ("Failed to read image stream: " + filePathOrUrl );
3037 throw e ;
31- }
38+ } finally { is . close ();}
3239 }
3340
3441 private static GXFile getGXFile (String filePathOrUrl ) {
You can’t perform that action at this time.
0 commit comments