Skip to content

Commit 4053e23

Browse files
Add public url support (#9)
1 parent fabc9b9 commit 4053e23

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/AzureBlobStorageAdapter.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
use League\Flysystem\UnableToRetrieveMetadata;
2929
use League\Flysystem\UnableToSetVisibility;
3030
use League\Flysystem\UnableToWriteFile;
31+
use League\Flysystem\UrlGeneration\PublicUrlGenerator;
3132
use League\Flysystem\UrlGeneration\TemporaryUrlGenerator;
3233
use League\MimeTypeDetection\FinfoMimeTypeDetector;
3334
use League\MimeTypeDetection\MimeTypeDetector;
3435

35-
final class AzureBlobStorageAdapter implements FilesystemAdapter, ChecksumProvider, TemporaryUrlGenerator
36+
final class AzureBlobStorageAdapter implements FilesystemAdapter, ChecksumProvider, TemporaryUrlGenerator, PublicUrlGenerator
3637
{
3738
public const ON_VISIBILITY_THROW_ERROR = 'throw';
3839
public const ON_VISIBILITY_IGNORE = 'ignore';
@@ -282,6 +283,14 @@ public function copy(string $source, string $destination, Config $config): void
282283
}
283284
}
284285

286+
/**
287+
* @description Azure doesn't support permanent URLs. Instead, we create one that lasts 1000 years.
288+
*/
289+
public function publicUrl(string $path, Config $config): string
290+
{
291+
return $this->temporaryUrl($path, (new \DateTimeImmutable())->modify("+1000 years"), $config);
292+
}
293+
285294
public function temporaryUrl(string $path, \DateTimeInterface $expiresAt, Config $config): string
286295
{
287296
$permissions = $config->get("permissions", "r");

0 commit comments

Comments
 (0)