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

@ -30,7 +30,8 @@ class ObjectUploader implements PromisorInterface
/**
* @param S3ClientInterface $client The S3 Client used to execute
* the upload command(s).
* @param string $bucket Bucket to upload the object.
* @param string $bucket Bucket to upload the object, or
* an S3 access point ARN.
* @param string $key Key of the object.
* @param mixed $body Object data to upload. Can be a
* StreamInterface, PHP stream
@ -70,19 +71,19 @@ class ObjectUploader implements PromisorInterface
'key' => $this->key,
'acl' => $this->acl
] + $this->options))->promise();
} else {
// Perform a regular PutObject operation.
$command = $this->client->getCommand('PutObject', [
'Bucket' => $this->bucket,
'Key' => $this->key,
'Body' => $this->body,
'ACL' => $this->acl,
] + $this->options['params']);
if (is_callable($this->options['before_upload'])) {
$this->options['before_upload']($command);
}
return $this->client->executeAsync($command);
}
// Perform a regular PutObject operation.
$command = $this->client->getCommand('PutObject', [
'Bucket' => $this->bucket,
'Key' => $this->key,
'Body' => $this->body,
'ACL' => $this->acl,
] + $this->options['params']);
if (is_callable($this->options['before_upload'])) {
$this->options['before_upload']($command);
}
return $this->client->executeAsync($command);
}
public function upload()
@ -123,7 +124,7 @@ class ObjectUploader implements PromisorInterface
}
// If body >= 5 MB, then use multipart. [YES]
if ($body->isSeekable()) {
if ($body->isSeekable() && $body->getMetadata('uri') !== 'php://input') {
// If the body is seekable, just rewind the body.
$body->seek(0);
} else {