How can i store image in my project hosted in openshift?

戏子无情 提交于 2019-12-11 08:56:45

问题


i am trying to create chart and save chart in image folder. it works fine locally but when i hosted it in openshift online it doesn't work.

String root = getServletContext().getRealPath("/");
   File savedFile = new File(root+"\\images\\piechart.jpg");
   ChartUtilities.saveChartAsJPEG(savedFile, piechart, 700, 400); 

root gives null so saving is not working ... please help to store image.


回答1:


Instead of saving the chart as an image in a local folder, you can use one of the variations of ChartUtilities.writeChartAs… to write the image to the servlet's OutputStream.

ChartUtilities.writeChartAsJPEG(response.getOutputStream(), …);
ChartUtilities.writeChartAsPNG(response.getOutputStream(), …);


来源:https://stackoverflow.com/questions/30430770/how-can-i-store-image-in-my-project-hosted-in-openshift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!