Class MultipartBody
- java.lang.Object
-
- org.asynchttpclient.request.body.multipart.MultipartBody
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Body,RandomAccessBody
public class MultipartBody extends Object implements RandomAccessBody
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.asynchttpclient.request.body.Body
Body.BodyState
-
-
Constructor Summary
Constructors Constructor Description MultipartBody(List<MultipartPart<? extends Part>> parts, String contentType, byte[] boundary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()byte[]getBoundary()longgetContentLength()Gets the length of the body.StringgetContentType()Body.BodyStatetransferTo(io.netty.buffer.ByteBuf target)Reads the next chunk of bytes from the body.longtransferTo(WritableByteChannel target)Transfers the specified chunk of bytes from this body to the specified channel.
-
-
-
Constructor Detail
-
MultipartBody
public MultipartBody(List<MultipartPart<? extends Part>> parts, String contentType, byte[] boundary)
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getContentLength
public long getContentLength()
Description copied from interface:BodyGets the length of the body.- Specified by:
getContentLengthin interfaceBody- Returns:
- The length of the body in bytes, or negative if unknown.
-
getContentType
public String getContentType()
-
getBoundary
public byte[] getBoundary()
-
transferTo
public Body.BodyState transferTo(io.netty.buffer.ByteBuf target) throws IOException
Description copied from interface:BodyReads the next chunk of bytes from the body.- Specified by:
transferToin interfaceBody- Parameters:
target- The buffer to store the chunk in, must not benull.- Returns:
- The state.
- Throws:
IOException- If the chunk could not be read.
-
transferTo
public long transferTo(WritableByteChannel target) throws IOException
Description copied from interface:RandomAccessBodyTransfers the specified chunk of bytes from this body to the specified channel.- Specified by:
transferToin interfaceRandomAccessBody- Parameters:
target- The destination channel to transfer the body chunk to, must not benull.- Returns:
- The non-negative number of bytes actually transferred.
- Throws:
IOException- If the body chunk could not be transferred.
-
-