com.amazonaws.auth
Class AwsChunkedEncodingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.amazonaws.internal.SdkInputStream
          extended by com.amazonaws.auth.AwsChunkedEncodingInputStream
All Implemented Interfaces:
com.amazonaws.internal.MetricAware, java.io.Closeable

public final class AwsChunkedEncodingInputStream
extends com.amazonaws.internal.SdkInputStream

A wrapper class of InputStream that implements chunked-encoding.


Constructor Summary
AwsChunkedEncodingInputStream(java.io.InputStream in, byte[] kSigning, java.lang.String datetime, java.lang.String keyPath, java.lang.String headerSignature, AWS4Signer aws4Signer)
           
AwsChunkedEncodingInputStream(java.io.InputStream in, int maxBufferSize, byte[] kSigning, java.lang.String datetime, java.lang.String keyPath, java.lang.String headerSignature, AWS4Signer aws4Signer)
          A wrapper of InputStream that implements pseudo-chunked-encoding.
 
Method Summary
static long calculateStreamContentLength(long originalLength)
           
 void mark(int readlimit)
          The readlimit parameter is ignored.
 boolean markSupported()
           
 int read()
           
 int read(byte[] b, int off, int len)
           
 void reset()
          Reset the stream, either by resetting the wrapped stream or using the buffer created by this class.
 long skip(long n)
           
 
Methods inherited from class com.amazonaws.internal.SdkInputStream
isMetricActivated
 
Methods inherited from class java.io.InputStream
available, close, read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AwsChunkedEncodingInputStream

public AwsChunkedEncodingInputStream(java.io.InputStream in,
                                     byte[] kSigning,
                                     java.lang.String datetime,
                                     java.lang.String keyPath,
                                     java.lang.String headerSignature,
                                     AWS4Signer aws4Signer)

AwsChunkedEncodingInputStream

public AwsChunkedEncodingInputStream(java.io.InputStream in,
                                     int maxBufferSize,
                                     byte[] kSigning,
                                     java.lang.String datetime,
                                     java.lang.String keyPath,
                                     java.lang.String headerSignature,
                                     AWS4Signer aws4Signer)
A wrapper of InputStream that implements pseudo-chunked-encoding. Each chunk will be buffered for the calculation of the chunk signature which is added at the head of each chunk.
The default chunk size cannot be customized, since we need to calculate the expected encoded stream length before reading the wrapped stream.
This class will use the mark() & reset() of the wrapped InputStream if they are supported, otherwise it will create a buffer for bytes read from the wrapped stream.

Parameters:
in - The original InputStream.
maxBufferSize - Maximum number of bytes buffered by this class.
kSigning - Signing key.
datetime - Datetime, as used in SigV4.
keyPath - Keypath/Scope, as used in SigV4.
headerSignature - The signature of the signed headers. This will be used for calculating the signature of the first chunk.
aws4Signer - The AWS4Signer used for hashing and signing.
Method Detail

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream
See Also:
InputStream.markSupported()

mark

public void mark(int readlimit)
The readlimit parameter is ignored.

Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Reset the stream, either by resetting the wrapped stream or using the buffer created by this class.

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

calculateStreamContentLength

public static long calculateStreamContentLength(long originalLength)


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.