Table of Contents

Class ChunkedUploadWrapperStream

Namespace
Amazon.Runtime.Internal.Util
Assembly
AWSSDK.Core.dll

Stream wrapper that double-buffers from a wrapped stream and returns the buffered content as a series of signed 'chunks' for the AWS4 ('Signature V4') protocol or the asymmetric Sigv4 (Sigv4a) protocol.

public class ChunkedUploadWrapperStream : WrapperStream, IDisposable, IAsyncDisposable
Inheritance
ChunkedUploadWrapperStream
Implements
Inherited Members

Constructors

ChunkedUploadWrapperStream(Stream, int, AWSSigningResultBase, CoreChecksumAlgorithm, IDictionary<string, string>)

Initializes a chunked upload stream with one or more trailing headers, which may include a trailing checksum header

public ChunkedUploadWrapperStream(Stream stream, int wrappedStreamBufferSize, AWSSigningResultBase headerSigningResult, CoreChecksumAlgorithm trailingChecksum, IDictionary<string, string> trailingHeaders)

Parameters

stream Stream

Stream to wrap

wrappedStreamBufferSize int

Size of buffer used for reading from stream

headerSigningResult AWSSigningResultBase

SigV4 or SigV4a signing result for the request's headers

trailingChecksum CoreChecksumAlgorithm

Algorithm to use to calculate the stream's checksum

trailingHeaders IDictionary<string, string>

Trailing headers to append after the wrapped stream

Fields

DefaultChunkSize

public static readonly int DefaultChunkSize

Field Value

int

V4A_SIGNATURE_LENGTH

public const int V4A_SIGNATURE_LENGTH = 144

Field Value

int

V4_SIGNATURE_LENGTH

public const int V4_SIGNATURE_LENGTH = 64

Field Value

int

Properties

CanSeek

Gets a value indicating whether the current stream supports seeking. True if the stream supports seeking; otherwise, false.

public override bool CanSeek { get; }

Property Value

bool

Length

Length override to return the true length of the payload plus the metainfo supplied with each chunk

public override long Length { get; }

Property Value

long

Methods

BuildChunkedStringToSign(string, string, string, string, int, byte[])

Builds the string to sign for a single V4/V4a chunk

public static string BuildChunkedStringToSign(string prefix, string dateTime, string scope, string previousSignature, int dataLength, byte[] inputBuffer)

Parameters

prefix string

Algorithm being used

dateTime string

ISO8601DateTime that we're signing the request for

scope string

Signing scope (date/region/service/aws4_request)

previousSignature string

Previous chunk's unpadded signature

dataLength int

Length of the content for this chunk

inputBuffer byte[]

Content of this chunk

Returns

string

The string to sign for this chunk

ComputeChunkedContentLength(long, int)

Computes the total size of the data payload, including the chunk metadata. Called externally so as to be able to set the correct Content-Length header value.

public static long ComputeChunkedContentLength(long originalLength, int signatureLength)

Parameters

originalLength long

Length of the wrapped stream

signatureLength int

Length of the signature for each chunk, in bytes

Returns

long

Total size of the wrapped payload, in bytes

ComputeChunkedContentLength(long, int, IDictionary<string, string>, CoreChecksumAlgorithm)

Computes the total size of the data payload, including the chunk metadata and optional trailing headers. Called externally so as to be able to set the correct Content-Length header value.

public static long ComputeChunkedContentLength(long originalLength, int signatureLength, IDictionary<string, string> trailingHeaders, CoreChecksumAlgorithm trailingChecksum)

Parameters

originalLength long

Length of the wrapped stream

signatureLength int

Length of the signature for each chunk, in bytes

trailingHeaders IDictionary<string, string>

Optional trailing headers

trailingChecksum CoreChecksumAlgorithm

Optional checksum algorithm for a trailing header

Returns

long

Total size of the wrapped payload, in bytes

Read(byte[], int, int)

Reads some or all of the processed chunk to the consumer, constructing and streaming a new chunk if more input data is available.

public override int Read(byte[] buffer, int offset, int count)

Parameters

buffer byte[]
offset int
count int

Returns

int

ReadAsync(byte[], int, int, CancellationToken)

public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)

Parameters

buffer byte[]
offset int
count int
cancellationToken CancellationToken

Returns

Task<int>