java.lang.Object
org.miaixz.bus.http.bodys.RequestBody
org.miaixz.bus.http.bodys.MultipartBody
A MIME multipart request body.
This class represents a composite request body of type multipart/related, used for uploading multiple parts
(such as files and form data). Each part is separated by a boundary and can have its own custom headers and content
type.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA builder for creatingMultipartBodyinstances.static final classA part of a multipart body. -
Method Summary
Modifier and TypeMethodDescriptionboundary()Returns the boundary separator.longReturns the length of this request body in bytes.org.miaixz.bus.core.lang.MediaTypeReturns the full media type, including the boundary.part(int index) Returns the part at the specified index.parts()Returns the list of parts.intsize()Returns the number of parts in this multipart body.org.miaixz.bus.core.lang.MediaTypetype()Returns the original media type.voidwriteTo(org.miaixz.bus.core.io.sink.BufferSink sink) Writes the content of this request body to the given sink.
-
Method Details
-
type
public org.miaixz.bus.core.lang.MediaType type()Returns the original media type.- Returns:
- The original media type.
-
boundary
Returns the boundary separator.- Returns:
- The boundary string.
-
size
public int size()Returns the number of parts in this multipart body.- Returns:
- The number of parts.
-
parts
Returns the list of parts.- Returns:
- An unmodifiable list of parts.
-
part
Returns the part at the specified index.- Parameters:
index- The index.- Returns:
- The part instance.
-
contentType
public org.miaixz.bus.core.lang.MediaType contentType()Returns the full media type, including the boundary.- Specified by:
contentTypein classRequestBody- Returns:
- The media type with the boundary.
-
contentLength
Returns the length of this request body in bytes.- Overrides:
contentLengthin classRequestBody- Returns:
- The content length.
- Throws:
IOException- if the length cannot be determined.
-
writeTo
Writes the content of this request body to the given sink.- Specified by:
writeToin classRequestBody- Parameters:
sink- The sink to write to.- Throws:
IOException- if an I/O error occurs.
-