Send generated image to browser using Play framework

前端 未结 2 2264
温柔的废话
温柔的废话 2020-12-30 17:10

I\'m trying to output a generated image using Play. I\'m not sure if my issue is Play-specific or not. I\'m trying to do the same thing this PHP code does:

         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 17:34

    There are a number of renderBinary methods, one of which simply takes a File as a parameter. See http://www.playframework.org/documentation/api/1.1/play/mvc/Controller.html#renderBinary(java.io.File)

    So, your code needs to be as simple as

    public static void map(String building_code, String ts_code) throws IOException {
        renderBinary(new File("public/images/maps/" + building_code + "_" + ts_code.charAt(0)));
    }
    

提交回复
热议问题