我正在使用发布于:PlayFramework: Ajax + Drag n' Drop + File Upload + File object in controller?的解决方案,但不成功 . 我总是得到一个java.io.IOException - 结果太大了 .

我正在尝试上传图片大小为1,64MB .... 2MB . 我的控制器代码在上述主题中是相同的 . TNKS .

public static void upload(String qqFile) {

    if (request.isNew) {

        FileOutputStream moveTo = null;


        // Another way I used to grab the name of the file
        String filename = request.headers.get("x-file-name").value();

        try {
            InputStream data = request.body;
            moveTo = new FileOutputStream(new File(Play.getFile("").getAbsolutePath()) + File.separator + "uploads" + File.separator + filename);
            IOUtils.copy(data, moveTo);

        } catch (Exception ex) {

            // catch file exception
            // catch IO Exception later on
            renderJSON("{success: " + ex.toString() + "}");
        }

    }

    renderJSON("{success: true}");
}