Class MultiPartFormContent
- java.lang.Object
-
- net.lenni0451.commons.httpclient.content.HttpContent
-
- net.lenni0451.commons.httpclient.content.impl.MultiPartFormContent
-
public class MultiPartFormContent extends HttpContent
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMultiPartFormContent.FormPart
-
Constructor Summary
Constructors Constructor Description MultiPartFormContent()MultiPartFormContent(java.lang.String boundary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiPartFormContentaddPart(java.lang.String name, HttpContent content)Add a new part to the form data.MultiPartFormContentaddPart(java.lang.String name, HttpContent content, java.lang.String fileName)Add a new part to the form data.MultiPartFormContentaddPart(MultiPartFormContent.FormPart part)Add a new part to the form data.booleancanBeStreamedMultipleTimes()Get if the content can be streamed multiple times.
The return value is allowed to change between multiple calls depending on the implementation.protected java.io.InputStreamcompute()Compute the content and return it as an input stream.
This method can be called multiple times ifHttpContent.canBeStreamedMultipleTimes()returnstrue.intgetLength()Get the content length in bytes.
If the content length is unknown, return-1.
Streaming the content may require valid content length depending on the implementation.-
Methods inherited from class net.lenni0451.commons.httpclient.content.HttpContent
bytes, bytes, clearCache, file, form, form, getAsBytes, getAsStream, getAsString, getAsString, getBufferSize, getContentLength, getContentType, getType, inputStream, modify, multiPartForm, setBufferSize, string, string, transferTo
-
-
-
-
Method Detail
-
addPart
public MultiPartFormContent addPart(java.lang.String name, HttpContent content)
Add a new part to the form data.- Parameters:
name- The name of the partcontent- The content of the part- Returns:
- This instance for chaining
- See Also:
MultiPartFormContent.FormPart
-
addPart
public MultiPartFormContent addPart(java.lang.String name, HttpContent content, @Nullable java.lang.String fileName)
Add a new part to the form data.- Parameters:
name- The name of the partcontent- The content of the partfileName- The file name of the part- Returns:
- This instance for chaining
-
addPart
public MultiPartFormContent addPart(MultiPartFormContent.FormPart part)
Add a new part to the form data.- Parameters:
part- The part to add- Returns:
- This instance for chaining
-
canBeStreamedMultipleTimes
public boolean canBeStreamedMultipleTimes()
Description copied from class:HttpContentGet if the content can be streamed multiple times.
The return value is allowed to change between multiple calls depending on the implementation.- Specified by:
canBeStreamedMultipleTimesin classHttpContent- Returns:
- If the content can be streamed multiple times
-
getLength
public int getLength()
Description copied from class:HttpContentGet the content length in bytes.
If the content length is unknown, return-1.
Streaming the content may require valid content length depending on the implementation.- Specified by:
getLengthin classHttpContent- Returns:
- The content length
-
compute
@Nonnull protected java.io.InputStream compute() throws java.io.IOExceptionDescription copied from class:HttpContentCompute the content and return it as an input stream.
This method can be called multiple times ifHttpContent.canBeStreamedMultipleTimes()returnstrue.- Specified by:
computein classHttpContent- Returns:
- The content
- Throws:
java.io.IOException- If an I/O error occurs
-
-