public class RequestBody extends Object
| Modifier and Type | Method | Description |
|---|---|---|
InputStream |
asStream() |
|
static RequestBody |
empty() |
Creates a
RequestBody with no content. |
long |
getContentLength() |
|
static RequestBody |
of(byte[] bytes) |
Creates a
RequestBody from a byte array. |
static RequestBody |
of(File file) |
Create a
RequestBody using the full contents of the specified file. |
static RequestBody |
of(InputStream inputStream,
long contentLength) |
Creates a
RequestBody from an input stream. |
static RequestBody |
of(String contents) |
Creates a
RequestBody from a string. |
static RequestBody |
of(ByteBuffer byteBuffer) |
Creates a
RequestBody from a ByteBuffer. |
static RequestBody |
of(Path path) |
Create a
RequestBody using the full contents of the specified file. |
public InputStream asStream()
InputStream.public long getContentLength()
RequestBody.public static RequestBody of(Path path)
RequestBody using the full contents of the specified file.path - File to send to the service.public static RequestBody of(File file)
RequestBody using the full contents of the specified file.file - File to send to the service.public static RequestBody of(InputStream inputStream, long contentLength)
RequestBody from an input stream. "Content-Length" must
be provided so that the SDK does not have to make two passes of the data.
This stream will be consumed and closed by the SDK. It should NOT be re-used after making an API call with it. It
should also 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.
inputStream - Input stream to send to the service.contentLength - Content length of data in input stream.public static RequestBody of(String contents)
RequestBody from a string. String is sent as UTF-8 encoded bytes.contents - String to send to the service.public static RequestBody of(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 of(ByteBuffer byteBuffer)
RequestBody from a ByteBuffer. Buffer contents are copied so any modifications
made to the original ByteBuffer are not reflected in the RequestBody.byteBuffer - ByteBuffer to send to the service.public static RequestBody empty()
RequestBody with no content.Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.