/**
  * Always add a x-amz-content-sha-256 for data integrity.
  */
 public function presign(RequestInterface $request, CredentialsInterface $credentials, $expires)
 {
     if (!$request->hasHeader('x-amz-content-sha256')) {
         $request = $request->withHeader('X-Amz-Content-Sha256', $this->getPresignedPayload($request));
     }
     return parent::presign($request, $credentials, $expires);
 }
예제 #2
0
 /**
  * Always add a x-amz-content-sha-256 for data integrity.
  */
 public function presign(RequestInterface $request, CredentialsInterface $credentials, $expires)
 {
     /*
      * Don't send this imcompatible header
      */
     //if (!$request->hasHeader('x-amz-content-sha256')) {
     //    $request = $request->withHeader(
     //        'X-Amz-Content-Sha256',
     //        $this->getPresignedPayload($request)
     //    );
     //}
     return parent::presign($request, $credentials, $expires);
 }
예제 #3
0
 /**
  * Create a pre-signed URL for Polly operation `SynthesizeSpeech`
  *
  * @param array $args parameters array for `SynthesizeSpeech`
  *                    More information @see Aws\Polly\PollyClient::SynthesizeSpeech
  *
  * @return string
  */
 public function createSynthesizeSpeechPreSignedUrl(array $args)
 {
     $uri = new Uri($this->getEndpoint());
     $uri = $uri->withPath('/v1/speech');
     // Formatting parameters follows rest-json protocol
     $this->formatter = $this->formatter ?: new JsonBody($this->getApi());
     $queryArray = json_decode($this->formatter->build($this->getApi()->getOperation('SynthesizeSpeech')->getInput(), $args), true);
     // Mocking a 'GET' request in pre-signing the Url
     $query = Psr7\build_query($queryArray);
     $uri = $uri->withQuery($query);
     $request = new Request('GET', $uri);
     $request = $request->withBody(Psr7\stream_for(''));
     $signer = new SignatureV4('polly', $this->getRegion());
     return (string) $signer->presign($request, $this->getCredentials()->wait(), '+15 minutes')->getUri();
 }
 private function createPresignedUrl(AwsClientInterface $client, CommandInterface $cmd)
 {
     $newCmd = $client->getCommand('CopySnapshot', $cmd->toArray());
     // Avoid infinite recursion by flagging the new command.
     $newCmd->__skipCopySnapshot = true;
     // Serialize a request for the CopySnapshot operation.
     $request = \Aws\serialize($newCmd);
     // Create the new endpoint for the target endpoint.
     $endpoint = EndpointProvider::resolve($this->endpointProvider, ['region' => $cmd['SourceRegion'], 'service' => 'ec2'])['endpoint'];
     // Set the request to hit the target endpoint.
     $uri = $request->getUri()->withHost((new Uri($endpoint))->getHost());
     $request = $request->withUri($uri);
     // Create a presigned URL for our generated request.
     $signer = new SignatureV4('ec2', $cmd['SourceRegion']);
     return (string) $signer->presign(SignatureV4::convertPostToGet($request), $client->getCredentials()->wait(), '+1 hour')->getUri();
 }