|
5 | 5 | namespace AzureOss\FlysystemAzureBlobStorage; |
6 | 6 |
|
7 | 7 | use AzureOss\Storage\Blob\BlobContainerClient; |
| 8 | +use AzureOss\Storage\Blob\Exceptions\UnableToGenerateSasException; |
8 | 9 | use AzureOss\Storage\Blob\Models\Blob; |
9 | 10 | use AzureOss\Storage\Blob\Models\BlobProperties; |
10 | 11 | use AzureOss\Storage\Blob\Models\GetBlobsOptions; |
|
21 | 22 | use League\Flysystem\UnableToCopyFile; |
22 | 23 | use League\Flysystem\UnableToDeleteDirectory; |
23 | 24 | use League\Flysystem\UnableToDeleteFile; |
| 25 | +use League\Flysystem\UnableToGenerateTemporaryUrl; |
24 | 26 | use League\Flysystem\UnableToListContents; |
25 | 27 | use League\Flysystem\UnableToMoveFile; |
26 | 28 | use League\Flysystem\UnableToProvideChecksum; |
@@ -367,16 +369,20 @@ public function temporaryUrl(string $path, \DateTimeInterface $expiresAt, Config |
367 | 369 | { |
368 | 370 | $permissions = $config->get("permissions", "r"); |
369 | 371 | if (!is_string($permissions)) { |
370 | | - throw new \InvalidArgumentException("permissions must be a string!"); |
| 372 | + throw new UnableToGenerateTemporaryUrl("permissions must be a string!", $path); |
371 | 373 | } |
372 | 374 |
|
373 | 375 | $sasBuilder = BlobSasBuilder::new() |
374 | 376 | ->setExpiresOn($expiresAt) |
375 | 377 | ->setPermissions($permissions); |
376 | 378 |
|
377 | | - $sas = $this->containerClient |
378 | | - ->getBlobClient($this->prefixer->prefixPath($path)) |
379 | | - ->generateSasUri($sasBuilder); |
| 379 | + try { |
| 380 | + $sas = $this->containerClient |
| 381 | + ->getBlobClient($this->prefixer->prefixPath($path)) |
| 382 | + ->generateSasUri($sasBuilder); |
| 383 | + } catch (UnableToGenerateSasException $exception) { |
| 384 | + throw new UnableToGenerateTemporaryUrl($exception->getMessage(), $path, $exception); |
| 385 | + } |
380 | 386 |
|
381 | 387 | return (string) $sas; |
382 | 388 | } |
|
0 commit comments