MultipartUploader
extends AbstractUploader
in package
Encapsulates the execution of a multipart upload to Glacier.
Table of Contents
- PART_MIN_SIZE = 1048576
- $source : StreamInterface
- $validPartSizes : mixed
- __construct() : mixed
- Creates a multipart upload for a Glacier archive.
- getStateFromService() : UploadState
- Creates an UploadState object for a multipart upload by querying the service for the specified upload's information.
- createPart() : array<string|int, mixed>|null
- Generates the parameters for an upload part by analyzing a range of the source starting from the current offset up to the part size.
- determinePartSize() : mixed
- getCompleteParams() : mixed
- getInitiateParams() : mixed
- getNumberOfParts() : mixed
- getUploadCommands() : mixed
- handleResult() : mixed
- limitPartStream() : LimitStream
- Create a stream for a part that starts at the current position and has a length of the upload part size (or less with the final part).
- loadUploadWorkflowInfo() : mixed
- decorateWithHashes() : StreamInterface
- Decorates a stream with a tree AND linear sha256 hashing stream.
- determineSource() : StreamInterface
- Turns the provided source into a stream and stores it.
- isEof() : bool
- Checks if the source is at EOF.
- parseRange() : array<string|int, mixed>
- Parses a Glacier range string into a size and part number.
Constants
PART_MIN_SIZE
public
mixed
PART_MIN_SIZE
= 1048576
Properties
$source
protected
StreamInterface
$source
Source of the data to be uploaded.
$validPartSizes
private
static mixed
$validPartSizes
= [
1048576,
// 1 MB
2097152,
// 2 MB
4194304,
// 4 MB
8388608,
// 8 MB
16777216,
// 16 MB
33554432,
// 32 MB
67108864,
// 64 MB
134217728,
// 128 MB
268435456,
// 256 MB
536870912,
// 512 MB
1073741824,
// 1 GB
2147483648,
// 2 GB
4294967296,
]
Methods
__construct()
Creates a multipart upload for a Glacier archive.
public
__construct(GlacierClient $client, mixed $source[, array<string|int, mixed> $config = [] ]) : mixed
The valid configuration options are as follows:
- account_id: (string, default=string('-')) Account ID for the archive being uploaded, if different from the account making the request.
- archive_description: (string) Description of the archive.
- before_complete: (callable) Callback to invoke before the
CompleteMultipartUploadoperation. The callback should have a function signature likefunction (Aws\Command $command) {...}. - before_initiate: (callable) Callback to invoke before the
InitiateMultipartUploadoperation. The callback should have a function signature likefunction (Aws\Command $command) {...}. - before_upload: (callable) Callback to invoke before any
UploadMultipartPartoperations. The callback should have a function signature likefunction (Aws\Command $command) {...}. - concurrency: (int, default=int(3)) Maximum number of concurrent
UploadMultipartPartoperations allowed during the multipart upload. - part_size: (int, default=int(1048576)) Part size, in bytes, to use when doing a multipart upload. This must between 1 MB and 4 GB, and must be a power of 2 (in megabytes).
- prepare_data_source: (callable) Callback to invoke before starting the
multipart upload workflow. The callback should have a function
signature like
function () {...}. - state: (Aws\Multipart\UploadState) An object that represents the state
of the multipart upload and that is used to resume a previous upload.
When this options is provided, the
account_id,key, andpart_sizeoptions are ignored. - vault_name: (string, required) Vault name to use for the archive being uploaded.
Parameters
- $client : GlacierClient
-
Client used for the upload.
- $source : mixed
-
Source of the data to upload.
- $config : array<string|int, mixed> = []
-
Configuration used to perform the upload.
Return values
mixed —getStateFromService()
Creates an UploadState object for a multipart upload by querying the service for the specified upload's information.
public
static getStateFromService(GlacierClient $client, string $vaultName, string $uploadId[, string $accountId = '-' ]) : UploadState
Parameters
- $client : GlacierClient
-
GlacierClient object to use.
- $vaultName : string
-
Vault name for the multipart upload.
- $uploadId : string
-
Upload ID for the multipart upload.
- $accountId : string = '-'
-
Account ID for the multipart upload.
Return values
UploadState —createPart()
Generates the parameters for an upload part by analyzing a range of the source starting from the current offset up to the part size.
protected
createPart(mixed $seekable, mixed $number) : array<string|int, mixed>|null
Parameters
- $seekable : mixed
- $number : mixed
Return values
array<string|int, mixed>|null —determinePartSize()
protected
determinePartSize() : mixed
Return values
mixed —getCompleteParams()
protected
getCompleteParams() : mixed
Return values
mixed —getInitiateParams()
protected
getInitiateParams() : mixed
Return values
mixed —getNumberOfParts()
protected
getNumberOfParts(mixed $partSize) : mixed
Parameters
- $partSize : mixed
Return values
mixed —getUploadCommands()
protected
getUploadCommands(callable $resultHandler) : mixed
Parameters
- $resultHandler : callable
Return values
mixed —handleResult()
protected
handleResult(CommandInterface $command, ResultInterface $result) : mixed
Parameters
- $command : CommandInterface
- $result : ResultInterface
Return values
mixed —limitPartStream()
Create a stream for a part that starts at the current position and has a length of the upload part size (or less with the final part).
protected
limitPartStream(StreamInterface $stream) : LimitStream
Parameters
- $stream : StreamInterface
Return values
LimitStream —loadUploadWorkflowInfo()
protected
loadUploadWorkflowInfo() : mixed
Return values
mixed —decorateWithHashes()
Decorates a stream with a tree AND linear sha256 hashing stream.
private
decorateWithHashes(StreamInterface $stream, array<string|int, mixed> &$data) : StreamInterface
Parameters
- $stream : StreamInterface
-
Stream to decorate.
- $data : array<string|int, mixed>
-
Data bag that results are injected into.
Return values
StreamInterface —determineSource()
Turns the provided source into a stream and stores it.
private
determineSource(mixed $source) : StreamInterface
If a string is provided, it is assumed to be a filename, otherwise, it
passes the value directly to Psr7\stream_for().
Parameters
- $source : mixed
Return values
StreamInterface —isEof()
Checks if the source is at EOF.
private
isEof(bool $seekable) : bool
Parameters
- $seekable : bool
Return values
bool —parseRange()
Parses a Glacier range string into a size and part number.
private
static parseRange(string $range, int $partSize) : array<string|int, mixed>
Parameters
- $range : string
-
Glacier range string (e.g., "bytes 5-5000/*")
- $partSize : int
-
The chosen part size