Documentation

Transfer
in package
implements PromisorInterface

Transfers files from the local filesystem to S3 or from S3 to the local filesystem.

This class does not support copying from the local filesystem to somewhere else on the local filesystem or from one S3 bucket to another.

Interfaces, Classes and Traits

PromisorInterface
Interface used with classes that return a promise.

Table of Contents

$before  : mixed
$client  : mixed
$concurrency  : mixed
$destination  : mixed
$mupThreshold  : mixed
$promise  : mixed
$s3Args  : mixed
$source  : mixed
$sourceMetadata  : mixed
__construct()  : mixed
When providing the $source argument, you may provide a string referencing the path to a directory on disk to upload, an s3 scheme URI that contains the bucket and key (e.g., "s3://bucket/key"), or an \Iterator object that yields strings containing filenames that are the path to a file on disk or an s3 scheme URI. The bucket portion of the s3 URI may be an S3 access point ARN. The "/key" portion of an s3 URI is optional.
promise()  : PromiseInterface
Transfers the files.
transfer()  : mixed
Transfers the files synchronously.
addDebugToBefore()  : mixed
createDownloadPromise()  : mixed
createS3Key()  : mixed
createUploadPromise()  : mixed
determineScheme()  : string
Parses the scheme from a filename.
getDownloadsIterator()  : Iterator
getS3Args()  : array<string|int, mixed>
Creates an array that contains Bucket and Key by parsing the filename.
getUploadsIterator()  : Iterator
normalizePath()  : string
Normalize a path so that it has UNIX-style directory separators and no trailing /
prepareTarget()  : mixed
resolveUri()  : mixed
upload()  : mixed
uploadMultipart()  : mixed

Properties

$mupThreshold

private mixed $mupThreshold

$sourceMetadata

private mixed $sourceMetadata

Methods

__construct()

When providing the $source argument, you may provide a string referencing the path to a directory on disk to upload, an s3 scheme URI that contains the bucket and key (e.g., "s3://bucket/key"), or an \Iterator object that yields strings containing filenames that are the path to a file on disk or an s3 scheme URI. The bucket portion of the s3 URI may be an S3 access point ARN. The "/key" portion of an s3 URI is optional.

public __construct(S3ClientInterface $client, string|Iterator $source, string $dest[, array<string|int, mixed> $options = [] ]) : mixed

When providing an iterator for the $source argument, you must also provide a 'base_dir' key value pair in the $options argument.

The $dest argument can be the path to a directory on disk or an s3 scheme URI (e.g., "s3://bucket/key").

The options array can contain the following key value pairs:

  • base_dir: (string) Base directory of the source, if $source is an iterator. If the $source option is not an array, then this option is ignored.
  • before: (callable) A callback to invoke before each transfer. The callback accepts a single argument: Aws\CommandInterface $command. The provided command will be either a GetObject, PutObject, InitiateMultipartUpload, or UploadPart command.
  • mup_threshold: (int) Size in bytes in which a multipart upload should be used instead of PutObject. Defaults to 20971520 (20 MB).
  • concurrency: (int, default=5) Number of files to upload concurrently. The ideal concurrency value will vary based on the number of files being uploaded and the average size of each file. Generally speaking, smaller files benefit from a higher concurrency while larger files will not.
  • debug: (bool) Set to true to print out debug information for transfers. Set to an fopen() resource to write to a specific stream rather than writing to STDOUT.
Parameters
$client : S3ClientInterface

Client used for transfers.

$source : string|Iterator

Where the files are transferred from.

$dest : string

Where the files are transferred to.

$options : array<string|int, mixed> = []

Hash of options.

Return values
mixed

transfer()

Transfers the files synchronously.

public transfer() : mixed
Return values
mixed

addDebugToBefore()

private addDebugToBefore(mixed $debug) : mixed
Parameters
$debug : mixed
Return values
mixed

createDownloadPromise()

private createDownloadPromise() : mixed
Return values
mixed

createS3Key()

private createS3Key(mixed $filename) : mixed
Parameters
$filename : mixed
Return values
mixed

createUploadPromise()

private createUploadPromise() : mixed
Return values
mixed

determineScheme()

Parses the scheme from a filename.

private determineScheme(string $path) : string
Parameters
$path : string

Path to parse.

Return values
string

getDownloadsIterator()

private getDownloadsIterator() : Iterator
Return values
Iterator

getS3Args()

Creates an array that contains Bucket and Key by parsing the filename.

private getS3Args(string $path) : array<string|int, mixed>
Parameters
$path : string

Path to parse.

Return values
array<string|int, mixed>

getUploadsIterator()

private getUploadsIterator() : Iterator
Return values
Iterator

normalizePath()

Normalize a path so that it has UNIX-style directory separators and no trailing /

private normalizePath(string $path) : string
Parameters
$path : string
Return values
string

prepareTarget()

private prepareTarget(mixed $targetPath) : mixed
Parameters
$targetPath : mixed
Return values
mixed

resolveUri()

private resolveUri(mixed $uri) : mixed
Parameters
$uri : mixed
Return values
mixed

upload()

private upload(mixed $filename) : mixed
Parameters
$filename : mixed
Return values
mixed

uploadMultipart()

private uploadMultipart(mixed $filename) : mixed
Parameters
$filename : mixed
Return values
mixed

Search results