/** * {@inheritdoc} */ public static function fromUploadId(AwsClientInterface $client, UploadIdInterface $uploadId) { $transferState = new self($uploadId); foreach ($client->getIterator('ListParts', $uploadId->toParams()) as $part) { $transferState->addPart(UploadPart::fromArray($part)); } return $transferState; }
private function createPresignedUrl(AwsClientInterface $client, CommandInterface $command) { // Create a temporary client used to generate the presigned URL $newClient = Ec2Client::factory(array('region' => $command['SourceRegion'], 'signature' => 'v4', 'credentials' => $client->getCredentials())); $preCommand = $newClient->getCommand('CopySnapshot', $command->toArray()); $preCommand['__internal'] = true; /** @var \Guzzle\Http\Message\EntityEnclosingRequest $preRequest */ $preRequest = $preCommand->prepare(); return $newClient->getSignature()->createPresignedUrl(SignatureV4::convertPostToGet($preRequest), $newClient->getCredentials(), '+1 hour'); }
/** * {@inheritdoc} */ public static function fromUploadId(AwsClientInterface $client, UploadIdInterface $uploadId) { $transferState = new static($uploadId); $listParts = $client->getIterator('ListParts', $uploadId->toParams()); foreach ($listParts as $part) { list($firstByte, $lastByte) = explode('-', $part['RangeInBytes']); $partSize = (double) $listParts->getLastResult()->get('PartSizeInBytes'); $partData = array('partNumber' => $firstByte / $partSize + 1, 'checksum' => $part['SHA256TreeHash'], 'contentHash' => self::ALREADY_UPLOADED, 'size' => $lastByte - $firstByte + 1, 'offset' => $firstByte); $transferState->addPart(UploadPart::fromArray($partData)); } return $transferState; }
/** * {@inheritdoc} * * @param string $assetAssetFile * @return boolean */ public function exists($assetAssetFile) { return $this->s3Client->doesObjectExist($this->bucket, $assetAssetFile); }