From b9d8135e3ecb6c883c076784fffae94b9381b64e Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Tue, 2 Dec 2025 10:04:10 +0100 Subject: [PATCH 1/3] 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 8027f8c1631afbb0a90352eceaa73fc81f85154b Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Tue, 16 Dec 2025 11:15:52 +0100 Subject: [PATCH 2/3] Update for fork --- README.md | 5 ++--- composer.json | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1a9a652..e3df7a9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Azure Storage Blob filesystem driver for Laravel -[![Latest Version on Packagist](https://img.shields.io/packagist/v/azure-oss/storage-blob-laravel.svg)](https://packagist.org/packages/azure-oss/storage-blob-laravel) -[![Packagist Downloads](https://img.shields.io/packagist/dm/azure-oss/storage-blob-laravel)](https://packagist.org/packages/azure-oss/storage-blob-laravel) +A fork of [Azure-OSS/azure-storage-php-adapter-laravel](https://github.com/Azure-OSS/azure-storage-php-adapter-laravel) with BIIGLE-specific modifications. ## Minimum Requirements @@ -11,7 +10,7 @@ Install the package using composer: ```shell -composer require azure-oss/storage-blob-laravel +composer require biigle/laravel-azure-storage ``` diff --git a/composer.json b/composer.json index 69bdbc4..7d3f875 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "azure-oss/storage-blob-laravel", + "name": "biigle/laravel-azure-storage", "description": "Azure Storage Blob filesystem driver for Laravel", "type": "library", "license": "MIT", @@ -17,6 +17,10 @@ { "name": "Brecht Vermeersch", "email": "brechtvermeersch@outlook.be" + }, + { + "name": "Martin Zurowietz", + "email": "m.zurowietz@uni-bielefeld.de" } ], "require": { From a45c734b20ed5a42a31dfe0236b05827d43ec3e9 Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Tue, 16 Dec 2025 11:23:04 +0100 Subject: [PATCH 3/3] Implement optional support for direct public URL as temporary URL --- src/AzureStorageBlobAdapter.php | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/AzureStorageBlobAdapter.php b/src/AzureStorageBlobAdapter.php index cb567de..000c3c4 100644 --- a/src/AzureStorageBlobAdapter.php +++ b/src/AzureStorageBlobAdapter.php @@ -8,6 +8,7 @@ use Illuminate\Filesystem\FilesystemAdapter; use League\Flysystem\Config; use League\Flysystem\Filesystem; +use League\Flysystem\UnableToGenerateTemporaryUrl; /** * @internal @@ -16,14 +17,22 @@ */ final class AzureStorageBlobAdapter extends FilesystemAdapter { + /** + * Set to true to use the direct public URL instead of generating a temporary URL. + * If true, also acts as a fallback for new temporary URLs if no account credentials + * were provided. + */ + public bool $useDirectPublicUrl; + /** * @param array{connection_string: string, container: string, prefix?: string, root?: string} $config */ public function __construct(array $config) { + $useDirectPublicUrl = $config['use_direct_public_url'] ?? false; $serviceClient = BlobServiceClient::fromConnectionString($config['connection_string']); $containerClient = $serviceClient->getContainerClient($config['container']); - $adapter = new AzureBlobStorageAdapter($containerClient, $config['prefix'] ?? $config['root'] ?? ''); + $adapter = new AzureBlobStorageAdapter($containerClient, $config['prefix'] ?? $config['root'] ?? '', useDirectPublicUrl: $useDirectPublicUrl); parent::__construct( new Filesystem($adapter, $config), @@ -44,7 +53,7 @@ public function url($path) */ public function providesTemporaryUrls() { - return $this->adapter->containerClient->sharedKeyCredentials instanceof StorageSharedKeyCredential; + return $this->adapter->containerClient->sharedKeyCredentials instanceof StorageSharedKeyCredential || $this->useDirectPublicUrl; } /** @@ -57,11 +66,19 @@ public function providesTemporaryUrls() /** @phpstan-ignore-next-line */ public function temporaryUrl($path, $expiration, array $options = []) { - return $this->adapter->temporaryUrl( - $path, - $expiration, - new Config(array_merge(['permissions' => 'r'], $options)) - ); + try { + return $this->adapter->temporaryUrl( + $path, + $expiration, + new Config(array_merge(['permissions' => 'r'], $options)) + ); + } catch (UnableToGenerateTemporaryUrl $e) { + if ($this->useDirectPublicUrl) { + return $this->url($path); + } else { + throw $e; + } + } } /**