RequestBody (AWS SDK for Java

RequestBody (AWS SDK for Java - 2.25.21)
public final class RequestBodyextends Object

Represents the body of an HTTP request. Must be provided for operations that have a streaming input. Offers various convenience factory methods from common sources of data (File, String, byte[], etc).

  • Method Summary

    long

    Deprecated.Create a RequestBody using the full contents of the specified file. Create a RequestBody using the full contents of the specified file.
  • Method Details

    • contentStreamProvider

      Returns:
      RequestBody as an InputStream.
    • contentLength

      Deprecated.
      Returns:
      Content length of RequestBody.
    • optionalContentLength

      Returns:
      Optional object of content length of RequestBody.
    • contentType

      Returns:
      Content type of RequestBody.
    • fromFile

      Create a RequestBody using the full contents of the specified file.
      Parameters:
      path - File to send to the service.
      Returns:
      RequestBody instance.
    • fromFile

      Create a RequestBody using the full contents of the specified file.
      Parameters:
      file - File to send to the service.
      Returns:
      RequestBody instance.
    • fromInputStream

      Parameters:
      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.
      Returns:
      RequestBody instance.
    • fromString

      Creates a RequestBody from a string. String is sent using the provided encoding.
      Parameters:
      contents - String to send to the service.
      cs - The Charset to use.
      Returns:
      RequestBody instance.
    • fromString

      Creates a RequestBody from a string. String is sent as UTF-8 encoded bytes.
      Parameters:
      contents - String to send to the service.
      Returns:
      RequestBody instance.
    • fromBytes

      Creates a 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.
      Parameters:
      bytes - The bytes to send to the service.
      Returns:
      RequestBody instance.
    • fromByteBuffer

      Parameters:
      byteBuffer - ByteBuffer to send to the service.
      Returns:
      RequestBody instance.
    • fromRemainingByteBuffer

      Creates a 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.
      Parameters:
      byteBuffer - ByteBuffer to send to the service.
      Returns:
      RequestBody instance.
    • empty

      Returns:
      RequestBody instance.
    • fromContentProvider

      Parameters:
      provider - The content provider.
      contentLength - The content length.
      mimeType - The MIME type of the content.
      Returns:
      The created RequestBody.
    • fromContentProvider

      Parameters:
      provider - The content provider.
      mimeType - The MIME type of the content.
      Returns:
      The created RequestBody.

You Might Also Like