From b9d8135e3ecb6c883c076784fffae94b9381b64e Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Tue, 2 Dec 2025 10:04:10 +0100 Subject: [PATCH 1/4] Add conditional providesTemporaryUrls() method Generating temporary URLs only works if sharedKeyCredentials are set. --- src/AzureStorageBlobAdapter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AzureStorageBlobAdapter.php b/src/AzureStorageBlobAdapter.php index f3334e5..cb567de 100644 --- a/src/AzureStorageBlobAdapter.php +++ b/src/AzureStorageBlobAdapter.php @@ -4,6 +4,7 @@ use AzureOss\FlysystemAzureBlobStorage\AzureBlobStorageAdapter; use AzureOss\Storage\Blob\BlobServiceClient; +use AzureOss\Storage\Common\Auth\StorageSharedKeyCredential; use Illuminate\Filesystem\FilesystemAdapter; use League\Flysystem\Config; use League\Flysystem\Filesystem; @@ -43,7 +44,7 @@ public function url($path) */ public function providesTemporaryUrls() { - return true; + return $this->adapter->containerClient->sharedKeyCredentials instanceof StorageSharedKeyCredential; } /** From a399639dfedb64e13e0b579eec50b93014943e9a Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Tue, 16 Dec 2025 11:41:13 +0100 Subject: [PATCH 2/4] Fix conditional public URL check The containerClient was not exposed by the adapter. --- src/AzureStorageBlobAdapter.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/AzureStorageBlobAdapter.php b/src/AzureStorageBlobAdapter.php index cb567de..f26326b 100644 --- a/src/AzureStorageBlobAdapter.php +++ b/src/AzureStorageBlobAdapter.php @@ -16,6 +16,12 @@ */ final class AzureStorageBlobAdapter extends FilesystemAdapter { + + /** + * Whether the configuration of this adapter allows temporary URLs. + */ + public bool $canProvideTemporaryUrls; + /** * @param array{connection_string: string, container: string, prefix?: string, root?: string} $config */ @@ -23,6 +29,7 @@ public function __construct(array $config) { $serviceClient = BlobServiceClient::fromConnectionString($config['connection_string']); $containerClient = $serviceClient->getContainerClient($config['container']); + $this->canProvideTemporaryUrls = $containerClient->sharedKeyCredentials instanceof StorageSharedKeyCredential; $adapter = new AzureBlobStorageAdapter($containerClient, $config['prefix'] ?? $config['root'] ?? ''); parent::__construct( @@ -44,7 +51,7 @@ public function url($path) */ public function providesTemporaryUrls() { - return $this->adapter->containerClient->sharedKeyCredentials instanceof StorageSharedKeyCredential; + return $this->canProvideTemporaryUrls; } /** From b76115c7ae3d62e36e765b715353bfaef91de4bc Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Tue, 16 Dec 2025 12:54:12 +0100 Subject: [PATCH 3/4] Simplify check for ability to generate temporary URLs --- src/AzureStorageBlobAdapter.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/AzureStorageBlobAdapter.php b/src/AzureStorageBlobAdapter.php index f26326b..87954c7 100644 --- a/src/AzureStorageBlobAdapter.php +++ b/src/AzureStorageBlobAdapter.php @@ -4,7 +4,6 @@ use AzureOss\FlysystemAzureBlobStorage\AzureBlobStorageAdapter; use AzureOss\Storage\Blob\BlobServiceClient; -use AzureOss\Storage\Common\Auth\StorageSharedKeyCredential; use Illuminate\Filesystem\FilesystemAdapter; use League\Flysystem\Config; use League\Flysystem\Filesystem; @@ -29,7 +28,7 @@ public function __construct(array $config) { $serviceClient = BlobServiceClient::fromConnectionString($config['connection_string']); $containerClient = $serviceClient->getContainerClient($config['container']); - $this->canProvideTemporaryUrls = $containerClient->sharedKeyCredentials instanceof StorageSharedKeyCredential; + $this->canProvideTemporaryUrls = $containerClient->canGenerateSasUri(); $adapter = new AzureBlobStorageAdapter($containerClient, $config['prefix'] ?? $config['root'] ?? ''); parent::__construct( From 6ee2a83e3ebca3d9822cc4431d68a70203e56a66 Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Wed, 17 Dec 2025 14:07:36 +0100 Subject: [PATCH 4/4] Fix formatting --- src/AzureStorageBlobAdapter.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AzureStorageBlobAdapter.php b/src/AzureStorageBlobAdapter.php index 87954c7..f977834 100644 --- a/src/AzureStorageBlobAdapter.php +++ b/src/AzureStorageBlobAdapter.php @@ -15,7 +15,6 @@ */ final class AzureStorageBlobAdapter extends FilesystemAdapter { - /** * Whether the configuration of this adapter allows temporary URLs. */