public final class RequestBody extends Object
| Modifier and Type | Method and Description | 
|---|---|
| long | contentLength() | 
| ContentStreamProvider | contentStreamProvider() | 
| String | contentType() | 
| static RequestBody | empty()Creates a  RequestBodywith no content. | 
| static RequestBody | fromByteBuffer(ByteBuffer byteBuffer)Creates a  RequestBodyfrom aByteBuffer. | 
| static RequestBody | fromBytes(byte[] bytes)Creates a  RequestBodyfrom a byte array. | 
| static RequestBody | fromContentProvider(ContentStreamProvider provider,
                   long contentLength,
                   String mimeType)Creates a  RequestBodyfrom the givenContentStreamProvider. | 
| static RequestBody | fromFile(File file)Create a  RequestBodyusing the full contents of the specified file. | 
| static RequestBody | fromFile(Path path)Create a  RequestBodyusing the full contents of the specified file. | 
| static RequestBody | fromInputStream(InputStream inputStream,
               long contentLength)Creates a  RequestBodyfrom an input stream. | 
| static RequestBody | fromRemainingByteBuffer(ByteBuffer byteBuffer)Creates a  RequestBodyfrom the remaining readable bytes from aByteBuffer. | 
| static RequestBody | fromString(String contents)Creates a  RequestBodyfrom a string. | 
| static RequestBody | fromString(String contents,
          Charset cs)Creates a  RequestBodyfrom a string. | 
public ContentStreamProvider contentStreamProvider()
InputStream.public long contentLength()
RequestBody.public String contentType()
RequestBody.public static RequestBody fromFile(Path path)
RequestBody using the full contents of the specified file.path - File to send to the service.public static RequestBody fromFile(File file)
RequestBody using the full contents of the specified file.file - File to send to the service.public static RequestBody fromInputStream(InputStream inputStream, long contentLength)
RequestBody from an input stream.  must
 be provided so that the SDK does not have to make two passes of the data.
 
 The stream will not be closed by the SDK. It is up to to caller of this method to close the stream. The stream
 should not be read outside of the SDK (by another thread) as it will change the state of the InputStream and
 could tamper with the sending of the request.
 
 To support resetting via ContentStreamProvider, this uses InputStream.reset() and uses a read limit of
 128 KiB. If you need more control, use fromContentProvider(ContentStreamProvider, long, String).
inputStream - Input stream to send to the service. The stream will not be closed by the SDK.contentLength - Content length of data in input stream.public static RequestBody fromString(String contents, Charset cs)
RequestBody from a string. String is sent using the provided encoding.contents - String to send to the service.cs - The Charset to use.public static RequestBody fromString(String contents)
RequestBody from a string. String is sent as UTF-8 encoded bytes.contents - String to send to the service.public static RequestBody fromBytes(byte[] bytes)
RequestBody from a byte array. The contents of the byte array are copied so modifications to the
 original byte array are not reflected in the RequestBody.bytes - The bytes to send to the service.public static RequestBody fromByteBuffer(ByteBuffer byteBuffer)
RequestBody from a ByteBuffer. Buffer contents are copied so any modifications
 made to the original ByteBuffer are not reflected in the RequestBody.
 
 NOTE: This method always copies the entire contents of the buffer, ignoring the current read position. Use
 fromRemainingByteBuffer(ByteBuffer) if you need it to copy only the remaining readable bytes.
byteBuffer - ByteBuffer to send to the service.public static RequestBody fromRemainingByteBuffer(ByteBuffer byteBuffer)
RequestBody from the remaining readable bytes from a ByteBuffer. Unlike
 fromByteBuffer(ByteBuffer), this method respects the current read position of the buffer and reads only
 the remaining bytes. The buffer is copied before reading so no changes are made to original buffer.byteBuffer - ByteBuffer to send to the service.public static RequestBody empty()
RequestBody with no content.public static RequestBody fromContentProvider(ContentStreamProvider provider, long contentLength, String mimeType)
RequestBody from the given ContentStreamProvider.provider - The content provider.contentLength - The content length.mimeType - The MIME type of the content.RequestBody.Copyright © 2020. All rights reserved.