MultipartCopy
extends AbstractUploadManager
in package
Uses
MultipartUploadingTrait
Table of Contents
Methods
- __construct() : mixed
- Creates a multipart upload for copying an S3 object.
- copy() : ResultInterface
- Alias of {@see self::upload()}.
- getStateFromService() : UploadState
- Creates an UploadState object for a multipart upload by querying the service for the specified upload's information.
- promise() : PromiseInterface
- Drives the multipart copy workflow:
Methods
__construct()
Creates a multipart upload for copying an S3 object.
public
__construct(S3ClientInterface $client, string|array<string|int, 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
UploadPartCopyoperations. 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.
- 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.
- 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. - metadata_directive: (string, default='COPY') 'COPY' or 'REPLACE'.
Caller-supplied
params['Metadata']does NOT change the directive, set this option explicitly to opt into REPLACE. When 'COPY', source metadata fields (Metadata, CacheControl, ContentDisposition, ContentEncoding, ContentLanguage, ContentType, Expires) are forwarded and any matching caller-supplied fields are dropped. When 'REPLACE', no source metadata is read and caller-supplied params are used as-is. - tags_directive: (string, default='UNSPECIFIED') 'UNSPECIFIED', 'COPY',
or 'REPLACE'. UNSPECIFIED means no tag work and any caller-supplied
params['Tagging']is dropped. COPY reads source tags via GetObjectTagging and writes them to the destination via PutObjectTagging after CompleteMultipartUpload. REPLACE skips the read and writes caller-suppliedparams['Tagging']to the destination. - annotations_directive: (string, default='UNSPECIFIED') 'UNSPECIFIED', 'COPY', or 'EXCLUDE'. UNSPECIFIED and EXCLUDE both skip annotation work. COPY reads source annotations via ListObjectAnnotations and per-name GetObjectAnnotation, then writes them to the destination via per-name PutObjectAnnotation.
- source_metadata: (Aws\ResultInterface) The result of a HeadObject call on the copy source. If not provided, the SDK makes a HeadObject request to obtain the source object's size and metadata. Providing this avoids the extra request.
- display_progress: (boolean) Set true to track status in 1/8th increments for upload.
Parameters
- $client : S3ClientInterface
- $source : string|array<string|int, mixed>
- $config : array<string|int, mixed> = []
copy()
Alias of {@see self::upload()}.
public
copy() : ResultInterface
Return values
ResultInterfacegetStateFromService()
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[, array<string|int, mixed> $config = [] ]) : 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.
- $config : array<string|int, mixed> = []
-
Optional config to retain on the state. Pass the directive keys (
metadata_directive,tags_directive,annotations_directive) the original copy was launched with so a resumedMultipartCopyreplays Phase 3 with the same behavior. The caller can also override directives on the resume by passing them again to theMultipartCopyconstructor.
Return values
UploadStatepromise()
Drives the multipart copy workflow:
public
promise() : PromiseInterface
Phase 1: Source reads. HeadObject (pins VersionId), then (no-op unless tags/annotations were opted in) GetObjectTagging and ListObjectAnnotations + per-name GetObjectAnnotation in parallel.
Phase 2: Multipart upload. CreateMultipartUpload, UploadPartCopy parts in parallel, CompleteMultipartUpload.
Phase 3 (optional): Destination writes (skipped unless tags/annotations were opted in). PutObjectTagging (atomic, fail-fast), then per-name PutObjectAnnotation in parallel with retries (partial failure is surfaced via MultipartCopyAnnotationException).