Class FormPart

java.lang.Object
build.serve.form.FormPart

public final class FormPart extends Object
A single part from a multipart/form-data request body.
Since:
Apr-2026
Author:
reed.vonredwitz
  • Method Details

    • name

      public String name()
      The form field name from the Content-Disposition header.
      Returns:
      the field name
    • filename

      public Optional<String> filename()
      The client-supplied filename, if this part represents a file upload.

      Any path components the client embedded (e.g. ../../etc/passwd) have already been stripped, so this is always a bare filename — safe to use as the final path segment when saving the upload, but callers should still resolve it against a known directory rather than trusting it as a full path.

      Returns:
      the filename, or empty for plain form fields
    • contentType

      public Optional<String> contentType()
      The Content-Type of this part, if declared.
      Returns:
      the content type, or empty if not specified
    • bytes

      public byte[] bytes()
      The raw bytes of this part's body.
      Returns:
      the part body as a byte array
    • value

      public String value()
      The part body decoded as a UTF-8 string.
      Returns:
      the part body as a string