NOTE: For Version 3 of the AWS SDK for PHP, please see the V3 User Guide and V3 API Reference.

# Class UploadPartGenerator

Generates UploadPart objects from a string/stream that encapsulate the data needed for upload requests

  Aws\Glacier\Model\MultipartUpload\UploadPartGenerator implements Serializable, IteratorAggregate, Countable

Namespace: Aws\Glacier\Model\MultipartUpload
Located at Aws/Glacier/Model/MultipartUpload/UploadPartGenerator.php

## Methods summary

- `public static` `factory ( string|resource|EntityBodyInterface $body, int $partSize )`

  Creates a UploadPartGenerator and wraps the upload body in a Guzzle EntityBody object

- `public static` `createSingleUploadPart ( string|resource|EntityBodyInterface $body )`

  Creates a single upload part (up to 4GB) useful for the UploadArchive operation

- `public` `__construct ( Guzzle\Http\EntityBodyInterface $body, int $partSize )`
- `public` `getUploadPart ( int $partNumber )`

  Returns a single upload part from the calculated uploads by part number. By default it returns the first, which is useful behavior if there is only one upload.

- `public` `getAllParts ( )`
- `public` `getArchiveSize ( )`
- `public` `getRootChecksum ( )`
- `public` `getPartSize ( )`
- `public` `serialize ( )`
- `public` `unserialize ( mixed $serialized )`
- `public` `getIterator ( )`
- `public` `count ( )`
- `protected` `generateUploadParts ( Guzzle\Http\EntityBodyInterface $body )`

  Performs the work of reading the body stream, creating tree hashes, and creating UploadPartContext objects

- `protected` `updateTotals ( Aws\Glacier\Model\MultipartUpload\UploadPart $part )`

  Updated the upload helper running totals and tree hash with the data from a complete upload part

## Methods detail

# `public static `Aws\Glacier\Model\MultipartUpload\UploadPartGenerator``
`factory( string|resource|`Guzzle\Http\EntityBodyInterface` $body, integer $partSize )`

Creates a UploadPartGenerator and wraps the upload body in a Guzzle EntityBody object

#### Parameters

$body
  `string|resource|`Guzzle\Http\EntityBodyInterface``
  $body The upload body
$partSize
  `integer`
  $partSize The size of parts to split the upload into

#### Returns

``Aws\Glacier\Model\MultipartUpload\UploadPartGenerator``
# `public static `Aws\Glacier\Model\MultipartUpload\UploadPart``
`createSingleUploadPart( string|resource|`Guzzle\Http\EntityBodyInterface` $body )`

Creates a single upload part (up to 4GB) useful for the UploadArchive operation

#### Parameters

$body
  `string|resource|`Guzzle\Http\EntityBodyInterface``
  $body The upload body

#### Returns

``Aws\Glacier\Model\MultipartUpload\UploadPart``

#### Throws

``Aws\Common\Exception\RuntimeException``
if the body ends up being larger than 4GB
# `public`
`__construct( `Guzzle\Http\EntityBodyInterface` $body, integer $partSize )`

#### Parameters

$body
  ``Guzzle\Http\EntityBodyInterface``
  $body The upload body
$partSize
  `integer`
  $partSize The size of parts to split the upload into. Default is the 4GB max

#### Throws

``Aws\Common\Exception\InvalidArgumentException``
when the part size is invalid (i.e. not a power of 2 of 1MB)
``Aws\Common\Exception\InvalidArgumentException``
when the body is not seekable (must be able to rewind after calculating hashes)
``Aws\Common\Exception\InvalidArgumentException``
when the archive size is less than one byte
# `public `Aws\Glacier\Model\MultipartUpload\UploadPart``
`getUploadPart( integer $partNumber )`

Returns a single upload part from the calculated uploads by part number. By default it returns the first, which is useful behavior if there is only one upload.

#### Parameters

$partNumber
  `integer`
  $partNumber The numerical index of the upload

#### Returns

``Aws\Glacier\Model\MultipartUpload\UploadPart``

#### Throws

``Aws\Common\Exception\OutOfBoundsException``
if the index of the upload doesn't exist
# `public array`
`getAllParts( )`

#### Returns

`array`
# `public array`
`getArchiveSize( )`

#### Returns

`array`
# `public string`
`getRootChecksum( )`

#### Returns

`string`
# `public string`
`getPartSize( )`

#### Returns

`string`
# `public`
`serialize( )`

#### Implementation of

`Serializable::serialize()`
# `public`
`unserialize( mixed $serialized )`

#### Implementation of

`Serializable::unserialize()`
# `public`
`getIterator( )`

#### Implementation of

`IteratorAggregate::getIterator()`
# `public`
`count( )`

#### Implementation of

`Countable::count()`
# `protected`
`generateUploadParts( `Guzzle\Http\EntityBodyInterface` $body )`

Performs the work of reading the body stream, creating tree hashes, and creating UploadPartContext objects

#### Parameters

$body
  ``Guzzle\Http\EntityBodyInterface``
  $body The body to create parts from

# `protected`
`updateTotals( `Aws\Glacier\Model\MultipartUpload\UploadPart` $part )`

Updated the upload helper running totals and tree hash with the data from a complete upload part

#### Parameters

$part
  ``Aws\Glacier\Model\MultipartUpload\UploadPart``
  $part The newly completed upload part

#### Throws

``Aws\Common\Exception\OverflowException``
if the maximum number of allowed upload parts is exceeded

### Magic methods summary

## Constants summary

`integer` | `MAX_NUM_PARTS` | `10000` | #

## Properties summary

`protected string` | $rootChecksum | # The root checksum (tree hash) of the entire entity body
`protected array` | $uploadParts | # List of upload parts generated by this helper
`protected integer` | $archiveSize | # The total size of the entire upload body
`protected integer` | $partSize | # Size of upload parts