Skip to content

Commit 59de3a7

Browse files
committed
fixed: fixed Laravel temporary URL issue overtrue/laravel-filesystem-cos#18
1 parent 62bbfc1 commit 59de3a7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/CosAdapter.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use League\Flysystem\Visibility;
2222
use Overtrue\CosClient\BucketClient;
2323
use Overtrue\CosClient\Exceptions\ClientException;
24-
use Overtrue\CosClient\Exceptions\InvalidConfigException;
2524
use Overtrue\CosClient\ObjectClient;
2625
use TheNorthMemory\Xml\Transformer;
2726

@@ -341,6 +340,19 @@ public function getUrl(string $path): string
341340
return $this->config['signed_url'] ? $this->getSignedUrl($path) : $this->getObjectClient()->getObjectUrl($prefixedPath);
342341
}
343342

343+
public function getTemporaryUrl(string $path, $expiration)
344+
{
345+
if ($expiresAt instanceof \DateTimeInterface) {
346+
$expiration = $expiresAt->getTimestamp();
347+
}
348+
349+
try {
350+
return $this->getSignedUrl($path, $expiration);
351+
} catch (\Throwable $exception) {
352+
throw UnableToGenerateTemporaryUrl::dueToError($path, $exception);
353+
}
354+
}
355+
344356
public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config $config): string
345357
{
346358
if ($expiresAt instanceof \DateTimeInterface) {

0 commit comments

Comments
 (0)