Reference: Multipart
Installation (Gradle)
dependencies {
implementation(platform("org.http4k:http4k-bom:5.34.0.0"))
implementation("org.http4k:http4k-multipart")
}
About
Multipart form support for fields and files, including a set of lens extensions for fields/files.
See the how-to guides for example use.
Receiving Binary content with http4k Contracts
With binary attachments, you need to turn ensure that the pre-flight validation does not eat the stream. This is possible by instructing http4k to ignore the incoming body for validation purposes:
routes += "/api/document-upload" meta {
preFlightExtraction = PreFlightExtraction.IgnoreBody
} bindContract POST to { req -> Response(OK) }