Package dev.relism.flash.api.multipart
Class Part
java.lang.Object
dev.relism.flash.api.multipart.Part
One part of a
multipart/form-data body produced by Multipart.
Two internal states:
- Buffered (text fields and
Multipart.parts()results) — body is in abyte[];stream(),materialize(), andtext()are all repeatable and free of I/O. - Streaming (file parts returned by
Multipart.file(String)) — body is a bounded socketInputStream; callstream()ormaterialize()exactly once, before requesting the next part fromMultipart.
-
Method Summary
Modifier and TypeMethodDescriptionContent-Typedeclared in the part headers, ornullif absent.filename()Original filename fromfilename="...", ornullfor text fields.booleanisFile()trueif this part has afilenameattribute (i.e.byte[]Materialises the body into abyte[].name()Field or file name fromContent-Disposition: form-data; name="...".stream()Returns anInputStreamover the part body.text()Decodes the body as UTF-8.
-
Method Details
-
name
Field or file name fromContent-Disposition: form-data; name="...". -
filename
Original filename fromfilename="...", ornullfor text fields. -
contentType
Content-Typedeclared in the part headers, ornullif absent. -
isFile
public boolean isFile()trueif this part has afilenameattribute (i.e. a file upload). -
stream
Returns anInputStreamover the part body. For buffered parts: returns a fresh reader each call. For streaming file parts: returns the raw socket stream — read once only. -
materialize
Materialises the body into abyte[]. Result is cached; safe to call repeatedly. For streaming file parts: triggers a full read from the socket on first call.- Throws:
IOException
-
text
Decodes the body as UTF-8. Materialises if needed; result is cached. For streaming file parts: triggers a full read from the socket on first call.- Throws:
IOException
-