Handling file uploads

Handling file uploads #

At present there are no special considerations for handling file uploads. From the official Vert.x Web documentation:

Any file uploads will be automatically streamed to the uploads directory, which is file-uploads by default.

Each file will be given an automatically generated file name.

app.post("/upload", (req, res) -> {
    Set<FileUpload> uploads = req.fileUploads
    // Use the files...
})

See the FileUpload API documentation for further information.

Additional configuration #

You can configure certain aspects of the request body handler.

Setting the file size limit #

Set the maximum size for file uploads using the app.http.maxBodySize setting:

app.http.maxBodySize = "10MB"

The body size is specified using a byte format.

Setting the file upload directory #

Set the directory to store file uploads using the app.http.fileUploadsDirectory setting:

app.http.fileUploadsDirectory = "file-uploads"
Reminder: Only multipart/form-data requests can transfer files.

Next: Rendering templates