Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Fixed MultipartUploader usage
Browse files Browse the repository at this point in the history
  • Loading branch information
fauvel committed Mar 14, 2017
1 parent 1880c7a commit c7082c7
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions library/CM/File/Filesystem/Adapter/AwsS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,14 @@ public function write($path, $content) {
}

public function writeStream($path, $stream) {
/** @var \Aws\S3\Model\MultipartUpload\UploadBuilder $uploader */
$uploadBuilder = \Aws\S3\Model\MultipartUpload\UploadBuilder::newInstance();
$uploadBuilder->setClient($this->_client);
$uploadBuilder->setSource($stream);
$uploadBuilder->setBucket($this->_bucket);
$uploadBuilder->setKey($this->_getAbsolutePath($path));
/** @var \Aws\Common\Model\MultipartUpload\TransferInterface $uploader */
$uploader = $uploadBuilder->build();
$uploader = new \Aws\S3\MultipartUploader($this->_client, $stream, [
'bucket' => $this->_bucket,
'key' => $this->_getAbsolutePath($path),
]);

try {
$uploader->upload();
} catch (\Aws\Common\Exception\MultipartUploadException $exception) {
$uploader->abort();
} catch (\Aws\Exception\MultipartUploadException $exception) {
throw new CM_Exception('AWS S3 Upload to path failed', null, [
'path' => $path,
'originalExceptionMessage' => $exception->getMessage(),
Expand Down

0 comments on commit c7082c7

Please sign in to comment.