public static void getImage(String fileName) {
File file = new File( "~/" + fileName );
response.contentType = "image/png";
renderBinary( file );
}
In this method response and renderBinary are showing errors
public static void getImage(String fileName) {
File file = new File( "~/" + fileName );
response.contentType = "image/png";
renderBinary( file );
}
In this method response and renderBinary are showing errors
The code that you are using is for Playframework 1.x, and it is not compatible with the 2.x version. These two versions are totally different.
As @rags mentioned, take a look at How to render a binary with play 2.0?
More explanations on Content-Type are available here: http://www.playframework.com/documentation/2.1.1/JavaResponse
public static Result getImage() throws IOException { File file = new File( "d:\Images\"+name+".jpg" );
return ok(org.apache.commons.io.FileUtils.readFileToByteArray(file)).as("image/jpeg");
}
Here I am using IOException because I am using file operations, this is another way used rather than renderBinary