/**
* Create a link to a S3 object from a bucket. If expiration is not empty, then it is used to create
* a signed URL
*
* @param string $object The object name (full path)
* @param string $bucket The bucket name
* @param string|int $expiration The Unix timestamp to expire at or a string that can be evaluated by strtotime
* @throws InvalidDomainNameException
* @return string
*/
public function __invoke($object, $bucket = '', $expiration = '')
{
$bucket = trim($bucket ?: $this->getDefaultBucket(), '/');
if (empty($bucket)) {
throw new InvalidDomainNameException('An empty bucket name was given');
}
if ($expiration) {
$command = $this->client->getCommand('GetObject', ['Bucket' => $bucket, 'Key' => $object]);
return $this->client->createPresignedRequest($command, $expiration)->getUri()->__toString();
} else {
return $this->client->getObjectUrl($bucket, $object);
}
}