v2: Updates

* Simplifies & beautifies everything
* Introduces a new Class system.
* Errors are defaulted to AWS's handler.
* New function names & more efficient handling.
* Should fix a majority of the errors.

Please read the README for more!
This commit is contained in:
Devang Srivastava 2020-09-28 15:32:51 +05:30
commit e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions

View file

@ -1,6 +1,8 @@
<?php
namespace Aws\S3;
use Aws\Arn\ArnParser;
use Aws\Multipart\AbstractUploadManager;
use Aws\ResultInterface;
use GuzzleHttp\Psr7;
@ -50,19 +52,25 @@ class MultipartCopy extends AbstractUploadManager
* result of executing a HeadObject command on the copy source.
*
* @param S3ClientInterface $client Client used for the upload.
* @param string $source Location of the data to be copied
* @param string $source Location of the data to be copied
* (in the form /<bucket>/<key>).
* @param array $config Configuration used to perform the upload.
* @param array $config Configuration used to perform the upload.
*/
public function __construct(
S3ClientInterface $client,
$source,
array $config = []
) {
$this->source = '/' . ltrim($source, '/');
parent::__construct($client, array_change_key_case($config) + [
'source_metadata' => null
]);
if (ArnParser::isArn($source)) {
$this->source = '';
} else {
$this->source = "/";
}
$this->source .= ltrim($source, '/');
parent::__construct(
$client,
array_change_key_case($config) + ['source_metadata' => null]
);
}
/**
@ -80,12 +88,12 @@ class MultipartCopy extends AbstractUploadManager
return [
'command' => [
'initiate' => 'CreateMultipartUpload',
'upload' => 'UploadPartCopy',
'upload' => 'UploadPartCopy',
'complete' => 'CompleteMultipartUpload',
],
'id' => [
'bucket' => 'Bucket',
'key' => 'Key',
'bucket' => 'Bucket',
'key' => 'Key',
'upload_id' => 'UploadId',
],
'part_num' => 'PartNumber',
@ -101,8 +109,7 @@ class MultipartCopy extends AbstractUploadManager
if (!$this->state->hasPartBeenUploaded($partNumber)) {
$command = $this->client->getCommand(
$this->info['command']['upload'],
$this->createPart($partNumber, $parts)
+ $this->getState()->getId()
$this->createPart($partNumber, $parts) + $this->getState()->getId()
);
$command->getHandlerList()->appendSign($resultHandler, 'mup');
yield $command;
@ -121,7 +128,13 @@ class MultipartCopy extends AbstractUploadManager
$data[$k] = $v;
}
$data['CopySource'] = $this->source;
list($bucket, $key) = explode('/', ltrim($this->source, '/'), 2);
$data['CopySource'] = '/' . $bucket . '/' . rawurlencode(
implode(
'/',
array_map('urlencode', explode('/', $key))
)
);
$data['PartNumber'] = $partNumber;
$defaultPartSize = $this->determinePartSize();