Class MultiPartFormData

java.lang.Object
org.eclipse.jetty.http.MultiPartFormData

public class MultiPartFormData extends Object

A CompletableFuture that is completed when a multipart/form-data content has been parsed asynchronously from a Content.Source.

Once the parsing of the multipart/form-data content completes successfully, objects of this class are completed with a MultiPartFormData.Parts object.

Objects of this class may be configured to save multipart files in a configurable directory, and configure the max size of such files, etc.

Typical usage:


 // Some headers that include Content-Type.
 HttpFields headers = ...;
 String boundary = MultiPart.extractBoundary(headers.get(HttpHeader.CONTENT_TYPE));

 // Some multipart/form-data content.
 Content.Source content = ...;

 // Create and configure MultiPartFormData.
 MultiPartFormData.Parser formData = new MultiPartFormData.Parser(boundary);
 // Where to store the files.
 formData.setFilesDirectory(Path.of("/tmp"));
 // Max 1 MiB files.
 formData.setMaxFileSize(1024 * 1024);

 // Parse the content.
 formData.parse(content)
     // When complete, use the parts.
     .thenAccept(parts -> ...);
 
See Also: