Package org.apache.juneau.http.entity
Record Class MultipartBody.MultipartPart
java.lang.Object
java.lang.Record
org.apache.juneau.http.entity.MultipartBody.MultipartPart
- Enclosing class:
- MultipartBody
public static record MultipartBody.MultipartPart(String name, String filename, String contentType, HttpBody body)
extends Record
A single part within a
MultipartBody.- Since:
- 9.2.1
-
Constructor Summary
ConstructorsConstructorDescriptionMultipartPart(String name, String filename, String contentType, HttpBody body) Compact constructor enforcing the documented non-null contract onnameandbody, and rejecting CR/LF and other control characters inname,filename, andcontentTypethat could otherwise inject an extra MIME header line into the multipart wire format. -
Method Summary
Modifier and TypeMethodDescriptionbody()Returns the value of thebodyrecord component.Returns the value of thecontentTyperecord component.final booleanIndicates whether some other object is "equal to" this one.static MultipartBody.MultipartPartCreates a text field part with no filename andtext/plain; charset=UTF-8content type.static MultipartBody.MultipartPartCreates a file upload part.filename()Returns the value of thefilenamerecord component.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.static MultipartBody.MultipartPartCreates a part from an arbitraryHttpBody.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
MultipartPart
Compact constructor enforcing the documented non-null contract onnameandbody, and rejecting CR/LF and other control characters inname,filename, andcontentTypethat could otherwise inject an extra MIME header line into the multipart wire format.
-
-
Method Details
-
field
Creates a text field part with no filename andtext/plain; charset=UTF-8content type.- Parameters:
name- The field name. Must not benull .value- The string value. Must not benull .- Returns:
- A new instance. Never
null .
-
file
Creates a file upload part.- Parameters:
name- The field name. Must not benull .file- The file to upload. Must not benull . ItsFile.getName()is validated like any otherfilename— a hostile name containing CR/LF or other control characters is rejected.contentType- The MIME content type for the file (e.g."application/pdf"). May benull .- Returns:
- A new instance. Never
null .
-
of
public static MultipartBody.MultipartPart of(String name, String filename, String contentType, HttpBody body) Creates a part from an arbitraryHttpBody.- Parameters:
name- The field name. Must not benull .filename- The filename to advertise inContent-Disposition. May benull .contentType- The MIME content type. May benull .body- The body content. Must not benull .- Returns:
- A new instance. Never
null .
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
filename
Returns the value of thefilenamerecord component.- Returns:
- the value of the
filenamerecord component
-
contentType
Returns the value of thecontentTyperecord component.- Returns:
- the value of the
contentTyperecord component
-
body
Returns the value of thebodyrecord component.- Returns:
- the value of the
bodyrecord component
-