Skip to content

Commit

Permalink
Merge pull request #1683 from smoench/async-aws-adapter-presign-options
Browse files Browse the repository at this point in the history
[AsyncAwsS3] adapt options for a temporary url same as in the AwsS3V3Adapter
  • Loading branch information
frankdejonge committed Jul 27, 2023
2 parents 5e01886 + 9dc18c3 commit b11cba4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/AsyncAwsS3/AsyncAwsS3Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use AsyncAws\Core\Exception\Http\ClientException;
use AsyncAws\Core\Stream\ResultStream;
use AsyncAws\S3\Input\GetObjectRequest;
use AsyncAws\S3\Result\HeadObjectOutput;
use AsyncAws\S3\S3Client;
use AsyncAws\S3\ValueObject\AwsObject;
Expand Down Expand Up @@ -526,10 +527,14 @@ public function checksum(string $path, Config $config): string

public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config $config): string
{
$location = $this->prefixer->prefixPath($path);

try {
return $this->client->getPresignedUrl($this->bucket, $location, DateTimeImmutable::createFromInterface($expiresAt));
$options = $config->get('get_object_options', []);
$request = new GetObjectRequest(array_merge($options, [
'Bucket' => $this->bucket,
'Key' => $this->prefixer->prefixPath($path),
]));

return $this->client->presign($request, DateTimeImmutable::createFromInterface($expiresAt));
} catch (Throwable $exception) {
throw UnableToGenerateTemporaryUrl::dueToError($path, $exception);
}
Expand Down

0 comments on commit b11cba4

Please sign in to comment.