Fork me on GitHub

Pippo has builtin support for upload. For a perfect running example see UploadDemo from pippo-demo module.

In what follows I will show you how simple it is to work with uploads.

public static void main(String[] args) {
    Pippo pippo = new Pippo();
    Application application = pippo.getApplication();
    // the following two lines are optional 
    application.setMaximumUploadSize(100 * 1024); // 100k

    application.GET("/", routeContext -> routeContext.render("upload"));

    application.POST("/upload", routeContext -> {
        // retrieves the value for 'file' input
        FileItem file = routeContext.getRequest().getFile("file");
        try {
            // write to disk
//            file.write(file.getSubmittedFileName()); // write the file in application upload location
            File uploadedFile = new File(file.getSubmittedFileName());

            // send response
            routeContext.send("Uploaded file to '" + uploadedFile + "'");
        } catch (IOException e) {
            throw new PippoRuntimeException(e); // to display the error stack as response


The content for upload template is:

        <form action="/upload" method="post" enctype="multipart/form-data">
            <input type="file" name="file">
            <input type="submit" value="Submit">