Submit
Path:
~
/
/
opt
/
psa
/
admin
/
plib
/
modules
/
letsencrypt
/
vendor
/
aws
/
aws-sdk-php
/
src
/
S3
/
File Content:
MultipartUploadingTrait.php
<?php namespace PleskLetsEncrypt\Aws\S3; use PleskLetsEncrypt\Aws\CommandInterface; use PleskLetsEncrypt\Aws\Multipart\UploadState; use PleskLetsEncrypt\Aws\ResultInterface; trait MultipartUploadingTrait { private $uploadedBytes = 0; /** * Creates an UploadState object for a multipart upload by querying the * service for the specified upload's information. * * @param S3ClientInterface $client S3Client used for the upload. * @param string $bucket Bucket for the multipart upload. * @param string $key Object key for the multipart upload. * @param string $uploadId Upload ID for the multipart upload. * * @return UploadState */ public static function getStateFromService(S3ClientInterface $client, $bucket, $key, $uploadId) { $state = new UploadState(['Bucket' => $bucket, 'Key' => $key, 'UploadId' => $uploadId]); foreach ($client->getPaginator('ListParts', $state->getId()) as $result) { // Get the part size from the first part in the first result. if (!$state->getPartSize()) { $state->setPartSize($result->search('Parts[0].Size')); } // Mark all the parts returned by ListParts as uploaded. foreach ($result['Parts'] as $part) { $state->markPartAsUploaded($part['PartNumber'], ['PartNumber' => $part['PartNumber'], 'ETag' => $part['ETag']]); } } $state->setStatus(UploadState::INITIATED); return $state; } protected function handleResult(CommandInterface $command, ResultInterface $result) { $partData = []; $partData['PartNumber'] = $command['PartNumber']; $partData['ETag'] = $this->extractETag($result); $commandName = $command->getName(); $checksumResult = $commandName === 'UploadPart' ? $result : $result[$commandName . 'Result']; if (isset($command['ChecksumAlgorithm'])) { $checksumMemberName = 'Checksum' . \strtoupper($command['ChecksumAlgorithm']); $partData[$checksumMemberName] = $checksumResult[$checksumMemberName] ?? null; } $this->getState()->markPartAsUploaded($command['PartNumber'], $partData); // Updates counter for uploaded bytes. $this->uploadedBytes += $command["ContentLength"]; // Sends uploaded bytes to progress tracker if getDisplayProgress set if ($this->displayProgress) { $this->getState()->getDisplayProgress($this->uploadedBytes); } } protected abstract function extractETag(ResultInterface $result); protected function getCompleteParams() { $config = $this->getConfig(); $params = isset($config['params']) ? $config['params'] : []; $params['MultipartUpload'] = ['Parts' => $this->getState()->getUploadedParts()]; return $params; } protected function determinePartSize() { // Make sure the part size is set. $partSize = $this->getConfig()['part_size'] ?: MultipartUploader::PART_MIN_SIZE; // Adjust the part size to be larger for known, x-large uploads. if ($sourceSize = $this->getSourceSize()) { $partSize = (int) \max($partSize, \ceil($sourceSize / MultipartUploader::PART_MAX_NUM)); } // Ensure that the part size follows the rules: 5 MB <= size <= 5 GB. if ($partSize < MultipartUploader::PART_MIN_SIZE || $partSize > MultipartUploader::PART_MAX_SIZE) { throw new \InvalidArgumentException('The part size must be no less ' . 'than 5 MB and no greater than 5 GB.'); } return $partSize; } protected function getInitiateParams() { $config = $this->getConfig(); $params = isset($config['params']) ? $config['params'] : []; if (isset($config['acl'])) { $params['ACL'] = $config['acl']; } // Set the ContentType if not already present if (empty($params['ContentType']) && ($type = $this->getSourceMimeType())) { $params['ContentType'] = $type; } return $params; } /** * @return UploadState */ protected abstract function getState(); /** * @return array */ protected abstract function getConfig(); /** * @return int */ protected abstract function getSourceSize(); /** * @return string|null */ protected abstract function getSourceMimeType(); }
Edit
Rename
Chmod
Delete
FILE
FOLDER
INFO
Name
Size
Permission
Action
Crypto
---
0755
Exception
---
0755
Parser
---
0755
RegionalEndpoint
---
0755
UseArnRegion
---
0755
AmbiguousSuccessParser.php
2068 bytes
0644
ApplyChecksumMiddleware.php
6488 bytes
0644
BatchDelete.php
7430 bytes
0644
BucketEndpointArnMiddleware.php
12719 bytes
0644
BucketEndpointMiddleware.php
3377 bytes
0644
CalculatesChecksumTrait.php
1959 bytes
0644
EndpointRegionHelperTrait.php
3008 bytes
0644
ExpiresParsingMiddleware.php
1356 bytes
0644
GetBucketLocationParser.php
1342 bytes
0644
MultipartCopy.php
8865 bytes
0644
MultipartUploader.php
6286 bytes
0644
MultipartUploadingTrait.php
4522 bytes
0644
ObjectCopier.php
5534 bytes
0644
ObjectUploader.php
5255 bytes
0644
PermanentRedirectMiddleware.php
1555 bytes
0644
PostObject.php
3710 bytes
0644
PostObjectV4.php
5121 bytes
0644
PutObjectUrlMiddleware.php
1509 bytes
0644
RetryableMalformedResponseParser.php
1392 bytes
0644
S3Client.php
54929 bytes
0644
S3ClientInterface.php
14103 bytes
0644
S3ClientTrait.php
9517 bytes
0644
S3EndpointMiddleware.php
10066 bytes
0644
S3MultiRegionClient.php
20183 bytes
0644
S3UriParser.php
4874 bytes
0644
SSECMiddleware.php
2265 bytes
0644
StreamWrapper.php
30777 bytes
0644
Transfer.php
15800 bytes
0644
ValidateResponseChecksumParser.php
4877 bytes
0644
N4ST4R_ID | Naxtarrr