Storing a png image in a directory

0
Hello, I am trying to integrate the jfree charts java library into my application, it is triggered by a microflow button. The way I am going about doing this is my creating the chart in my java action class and saving it as a png in my %PROJECTDEPLOYMENTDIR%\data\tmp\ directory. When I run the application, the chart is visible but it is not allowing me to save it in the specified directory. I am receiving an error that says access denied to write to this directory, it should just create the directory below. Here is the code that does this, File PieChart=new File("%PROJECTDEPLOYMENTDIR%/data/tmp/chart.png"); ChartUtilities.saveChartAsPNG(PieChart, chart, width, height); The reason I wrote to the directory is being the restrictions on Mendix Java actions says that I should be able to write to this directory without requiring special permissions. The error I keep getting is below. com.mendix.modules.microflowengine.MicroflowException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: java.security.AccessControlException: access denied ("java.io.FilePermission" "%PROJECTDEPLOYMENTDIR%\data\tmp\chart.png" "write") Will Mendix allow me to save a png in a directory during runtime, if not do I have any other options available for storing this png file. Thank you.
asked
2 answers
1

Just to confirm, in your action did you get the path by using this function: Core.getConfiguration().getTempPath()

in the folder provided by this function you should be able to write your image without any issues.

answered
0

In my program, I now have

File PieChart = Core.getConfiguration().getTempPath();

ChartUtilities.saveChartAsPNG(PieChart, chart, width, height);

It is creating a file path called PieChart and using a java charting library to write to the folder. It should let me write to the folder, I looked at the security.policy doc and it says it has no restrictions, but it is still not letting me write to this folder. It returns the error below:

com.mendix.modules.microflowengine.MicroflowException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: java.security.AccessControlException: access denied ("java.io.FilePermission" "C:\Users\Monique\Documents\JavaExtension-main_2\deployment\data\tmp" "write")

Does this have something to do with this being a png file I am trying to write, or maybe Mendix is not allowing me to use this charting library to write to this folder. It works fine in eclipse, but not in the Mendix application. Any suggestions would be helpful. Thank you.

answered