I have created an application to generate barcode images which store the images in public/images/barcode using the following code
String dir = Play.application().getFile("public/images/barcode").getAbsolutePath();
String barcode = "46062161";
BarcodePrinter.print(barcode,dir + "/"+barcode+".png");
public class BarcodePrinter{
private static void Save_image(Image image,String filePath)
{
try
{
BufferedImage bi = (BufferedImage) image;
File outputfile = new File(filePath);
ImageIO.write(bi, "png", outputfile);
} catch (IOException e)
{
Logger.info(e.getMessage());
}
}
}
and in my view file
@imgpath(barcode:String) = @{
"/assets/images/barcode/"+barcode+".png"
}
<img src="@imgpath(barcode)" />
this code work only on development and it does not work in heroku. I got this error from logs
java.io.FileNotFoundException: /app/target/../public/images/barcode/46062161.png (No such file or directory)
please help me to solve this problem. Thanks
You probably don’t want to write to the file system on heroku anyway. Here is the relevant part of the documentation:
The best solution would probably be a cloud storage service like S3.