File tree 2 files changed +12
-5
lines changed
common/src/main/java/com/genexus
java/src/main/java/com/genexus
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -63,5 +63,5 @@ public interface IHttpContext {
63
63
boolean isHttpContextNull ();
64
64
boolean isHttpContextWeb ();
65
65
66
-
66
+ String getContextPath ();
67
67
}
Original file line number Diff line number Diff line change 6
6
import java .awt .image .AffineTransformOp ;
7
7
import java .awt .image .BufferedImage ;
8
8
import java .io .*;
9
+ import java .net .URL ;
9
10
10
11
import com .genexus .db .driver .ResourceAccessControlList ;
11
12
import com .genexus .util .GxFileInfoSourceType ;
@@ -22,13 +23,19 @@ private static InputStream getInputStream(String filePathOrUrl) throws IOExcepti
22
23
23
24
private static BufferedImage createBufferedImageFromURI (String filePathOrUrl ) throws IOException
24
25
{
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 ();
26
34
return ImageIO .read (is );
27
- }
28
- catch (IOException e ) {
35
+ } catch (IOException e ) {
29
36
log .error ("Failed to read image stream: " + filePathOrUrl );
30
37
throw e ;
31
- }
38
+ } finally { is . close ();}
32
39
}
33
40
34
41
private static GXFile getGXFile (String filePathOrUrl ) {
You can’t perform that action at this time.
0 commit comments