0

I have a BufferedImage in my jersey post call and would like to save it on the server. I can save it to the file system but I want to save it to the server img folder.

EG localhost:8080/server/img

How do I achieve this?

skinnybrit51
  • 4,927
  • 7
  • 25
  • 28

1 Answers1

0

Use the getRealPath() method of the ServletContext ServletContext.getRealPath to find out the actual directory in your filesystem and save it there. In your case it can be like

String realPathOfImgFolder=req.getServletContext().getRealPath("/img");

Then save the file to this location and it will be available by http://localhost:8080/server/img/<image file name with extension>

prajeesh kumar
  • 1,916
  • 1
  • 17
  • 17