Skip to content

Commit

Permalink
Add getTemporaryUrl() for laravel FilesystemAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Feb 17, 2022
1 parent afbccab commit 902bb1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"require-dev": {
"phpunit/phpunit": "^9.5",
"mockery/mockery": "^1.0",
"brainmaestro/composer-git-hooks": "^2.7",
"friendsofphp/php-cs-fixer": "^3.0",
"league/flysystem-adapter-test-utilities": "^3.0"
},
Expand Down
12 changes: 12 additions & 0 deletions src/CosAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,18 @@ public function getUrl(string $path): string
return $this->config['signed_url'] ? $this->getSignedUrl($path) : $this->getObjectClient()->getObjectUrl($prefixedPath);
}

/**
* For laravel FilesystemAdapter.
*/
public function getTemporaryUrl($path, int|string|\DateTimeInterface $expiration): string
{
if ($expiration instanceof \DateTimeInterface) {
$expiration = $expiration->getTimestamp();
}

return $this->getSignedUrl($path, $expiration);
}

/**
* @throws \Overtrue\CosClient\Exceptions\InvalidConfigException
*/
Expand Down

0 comments on commit 902bb1f

Please sign in to comment.