in src/S3/Transfer.php [78:161]
public function __construct(
S3ClientInterface $client,
$source,
$dest,
array $options = []
) {
$this->client = $client;
// Prepare the destination.
$this->destination = $this->prepareTarget($dest);
if ($this->destination['scheme'] === 's3') {
$this->s3Args = $this->getS3Args($this->destination['path']);
}
// Prepare the source.
if (is_string($source)) {
$this->sourceMetadata = $this->prepareTarget($source);
$this->source = $source;
} elseif ($source instanceof Iterator) {
if (empty($options['base_dir'])) {
throw new \InvalidArgumentException('You must provide the source'
. ' argument as a string or provide the "base_dir" option.');
}
$this->sourceMetadata = $this->prepareTarget($options['base_dir']);
$this->source = $source;
} else {
throw new \InvalidArgumentException('source must be the path to a '
. 'directory or an iterator that yields file names.');
}
// Validate schemes.
if ($this->sourceMetadata['scheme'] === $this->destination['scheme']) {
throw new \InvalidArgumentException("You cannot copy from"
. " {$this->sourceMetadata['scheme']} to"
. " {$this->destination['scheme']}."
);
}
// Handle multipart-related options.
$this->concurrency = isset($options['concurrency'])
? $options['concurrency']
: MultipartUploader::DEFAULT_CONCURRENCY;
$this->mupThreshold = isset($options['mup_threshold'])
? $options['mup_threshold']
: 16777216;
if ($this->mupThreshold < MultipartUploader::PART_MIN_SIZE) {
throw new \InvalidArgumentException('mup_threshold must be >= 5MB');
}
// Handle "before" callback option.
if (isset($options['before'])) {
$this->before = $options['before'];
if (!is_callable($this->before)) {
throw new \InvalidArgumentException('before must be a callable.');
}
}
// Handle "after" callback option.
if (isset($options['after'])) {
$this->after = $options['after'];
if (!is_callable($this->after)) {
throw new \InvalidArgumentException('after must be a callable.');
}
}
// Handle "debug" option.
if (isset($options['debug'])) {
if ($options['debug'] === true) {
$options['debug'] = fopen('php://output', 'w');
}
if (is_resource($options['debug'])) {
$this->addDebugToBefore($options['debug']);
}
}
// Handle "add_content_md5" option.
$this->addContentMD5 = isset($options['add_content_md5'])
&& $options['add_content_md5'] === true;
MetricsBuilder::appendMetricsCaptureMiddleware(
$this->client->getHandlerList(),
MetricsBuilder::S3_TRANSFER
);
}