MultipartUploader
extends AbstractUploader
in package
Uses
MultipartUploadingTrait
Encapsulates the execution of a multipart upload to S3 or Glacier.
Table of Contents
- PART_MAX_NUM = 10000
- PART_MAX_SIZE = 5368709120
- PART_MIN_SIZE = 5242880
- $source : StreamInterface
- __construct() : mixed
- Creates a multipart upload for an S3 object.
- 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
- extractETag() : mixed
- getCompleteParams() : mixed
- getConfig() : array<string|int, mixed>
- getInitiateParams() : mixed
- getNumberOfParts() : mixed
- getSourceMimeType() : mixed
- getSourceSize() : mixed
- getState() : UploadState
- 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 sha256 linear hashing stream.
- determineSource() : StreamInterface
- Turns the provided source into a stream and stores it.
- isEof() : bool
- Checks if the source is at EOF.
Constants
PART_MAX_NUM
public
mixed
PART_MAX_NUM
= 10000
PART_MAX_SIZE
public
mixed
PART_MAX_SIZE
= 5368709120
PART_MIN_SIZE
public
mixed
PART_MIN_SIZE
= 5242880
Properties
$source
protected
StreamInterface
$source
Source of the data to be uploaded.
Methods
__construct()
Creates a multipart upload for an S3 object.
public
__construct(S3ClientInterface $client, mixed $source[, array<string|int, mixed> $config = [] ]) : mixed
The valid configuration options are as follows:
- acl: (string) ACL to set on the object being upload. Objects are private by default.
- 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
CreateMultipartUploadoperation. The callback should have a function signature likefunction (Aws\Command $command) {...}. - before_upload: (callable) Callback to invoke before any
UploadPartoperations. The callback should have a function signature likefunction (Aws\Command $command) {...}. - bucket: (string, required) Name of the bucket to which the object is being uploaded, or an S3 access point ARN.
- concurrency: (int, default=int(5)) Maximum number of concurrent
UploadPartoperations allowed during the multipart upload. - key: (string, required) Key to use for the object being uploaded.
- params: (array) An array of key/value parameters that will be applied to each of the sub-commands run by the uploader as a base. Auto-calculated options will override these parameters. If you need more granularity over parameters to each sub-command, use the before_* options detailed above to update the commands directly.
- part_size: (int, default=int(5242880)) Part size, in bytes, to use when doing a multipart upload. This must between 5 MB and 5 GB, inclusive.
- 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 option is provided, the
bucket,key, andpart_sizeoptions are ignored.
Parameters
- $client : S3ClientInterface
-
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(S3ClientInterface $client, string $bucket, string $key, string $uploadId) : UploadState
Parameters
- $client : S3ClientInterface
-
S3Client used for the upload.
- $bucket : string
-
Bucket for the multipart upload.
- $key : string
-
Object key for the multipart upload.
- $uploadId : string
-
Upload 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 —extractETag()
protected
extractETag(ResultInterface $result) : mixed
Parameters
- $result : ResultInterface
Return values
mixed —getCompleteParams()
protected
getCompleteParams() : mixed
Return values
mixed —getConfig()
protected
abstract getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed> —getInitiateParams()
protected
getInitiateParams() : mixed
Return values
mixed —getNumberOfParts()
protected
getNumberOfParts(mixed $partSize) : mixed
Parameters
- $partSize : mixed
Return values
mixed —getSourceMimeType()
protected
getSourceMimeType() : mixed
Return values
mixed —getSourceSize()
protected
getSourceSize() : mixed
Return values
mixed —getState()
protected
abstract getState() : UploadState
Return values
UploadState —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 sha256 linear hashing stream.
private
decorateWithHashes(StreamInterface $stream, array<string|int, mixed> &$data) : StreamInterface
Parameters
- $stream : StreamInterface
-
Stream to decorate.
- $data : array<string|int, mixed>
-
Part data to augment with the hash result.
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