44
55namespace AzureOss \FlysystemAzureBlobStorage ;
66
7- use AzureOss \Storage \Blob \ContainerClient ;
7+ use AzureOss \Storage \Blob \Clients \ ContainerClient ;
88use AzureOss \Storage \Blob \Options \ListBlobsOptions ;
99use AzureOss \Storage \Blob \Options \UploadBlockBlobOptions ;
10- use AzureOss \Storage \Common \SAS \BlobSASPermission ;
11- use AzureOss \Storage \Common \SAS \BlobSASSignatureValues ;
12- use AzureOss \Storage \Common \SAS \SasIpRange ;
13- use AzureOss \Storage \Common \SAS \SasProtocol ;
14- use AzureOss \Storage \Common \SAS \SharedAccessSignatureHelper ;
15- use DateTimeInterface ;
16- use League \Flysystem \CalculateChecksumFromStream ;
17- use League \Flysystem \ChecksumProvider ;
10+ use AzureOss \Storage \Blob \SAS \BlobSASPermissions ;
11+ use AzureOss \Storage \Blob \SAS \BlobSASQueryParameters ;
12+ use AzureOss \Storage \Blob \SAS \BlobSASSignatureValues ;
13+ use AzureOss \Storage \Common \SAS \SASProtocol ;
1814use League \Flysystem \Config ;
1915use League \Flysystem \DirectoryAttributes ;
2016use League \Flysystem \FileAttributes ;
2925use League \Flysystem \UnableToRetrieveMetadata ;
3026use League \Flysystem \UnableToSetVisibility ;
3127use League \Flysystem \UnableToWriteFile ;
32- use League \Flysystem \UrlGeneration \PublicUrlGenerator ;
3328use League \Flysystem \UrlGeneration \TemporaryUrlGenerator ;
3429use League \MimeTypeDetection \FinfoMimeTypeDetector ;
3530use League \MimeTypeDetection \MimeTypeDetector ;
3631
37- class AzureBlobStorageAdapter implements FilesystemAdapter, ChecksumProvider, PublicUrlGenerator, TemporaryUrlGenerator
32+ class AzureBlobStorageAdapter implements FilesystemAdapter, TemporaryUrlGenerator
3833{
39- use CalculateChecksumFromStream;
40-
4134 private readonly MimeTypeDetector $ mimeTypeDetector ;
4235
4336 public function __construct (
@@ -62,7 +55,7 @@ public function directoryExists(string $path): bool
6255 $ options = new ListBlobsOptions (
6356 prefix: $ this ->getPrefix ($ path ),
6457 maxResults: 1 ,
65- delimiter: "/ "
58+ delimiter: "/ " ,
6659 );
6760
6861 $ response = $ this ->containerClient ->listBlobs ($ options );
@@ -200,7 +193,7 @@ private function fetchMetadata(string $path): FileAttributes
200193 $ path ,
201194 fileSize: $ response ->contentLength ,
202195 lastModified: $ response ->lastModified ->getTimestamp (),
203- mimeType: $ response ->contentType
196+ mimeType: $ response ->contentType ,
204197 );
205198 }
206199
@@ -262,49 +255,31 @@ private function getPrefix(string $path): ?string
262255 return $ path === "" ? null : rtrim ($ path , "/ " ) . "/ " ;
263256 }
264257
265- public function checksum (string $ path , Config $ config ): string
266- {
267- return $ this ->calculateChecksumFromStream ($ path , $ config );
268- }
269-
270- public function publicUrl (string $ path , Config $ config ): string
258+ public function temporaryUrl (string $ path , \DateTimeInterface $ expiresAt , Config $ config ): string
271259 {
272260 $ url = $ this ->containerClient ->getBlobClient ($ path )->getUrl ();
273261
274- $ sasValues = new BlobSASSignatureValues (
275- $ path ,
276- $ config ->get ("cache_control " ),
277- $ config ->get ("container_name " ),
278- $ config ->get ("content_disposition " ),
279- $ config ->get ("content_encoding " ),
280- $ config ->get ("content_language " ),
281- $ config ->get ("content_type " ),
282- $ config ->get ("correlation_id " ),
283- $ config ->get ("encryption_scope " ),
284- $ config ->get ("expires_on " ),
285- $ config ->get ("identifier " ),
286- $ config ->get ("ip_range " ),
287- $ config ->get ("permissions " , [BlobSASPermission::READ ]),
288- $ config ->get ("preauthorized_agent_object_id " ),
289- $ config ->get ("protocol " ),
290- $ config ->get ("snapshot_time " ),
291- $ config ->get ("starts_on " ),
292- $ config ->get ("version " ),
293- $ config ->get ("version_id " ),
262+ $ values = new BlobSASSignatureValues (
263+ containerName: $ this ->containerClient ->containerName ,
264+ expiresOn: $ expiresAt ,
265+ blobName: $ path ,
266+ permissions: $ config ->get ("permissions " , (string ) new BlobSASPermissions (read: true )),
267+ identifier: $ config ->get ("identifier " ),
268+ startsOn: $ config ->get ("starts_on " ),
269+ cacheControl: $ config ->get ("cache_control " ),
270+ contentDisposition: $ config ->get ("content_disposition " ),
271+ contentEncoding: $ config ->get ("content_encoding " ),
272+ contentLanguage: $ config ->get ("content_language " ),
273+ contentType: $ config ->get ("content_type " ),
274+ encryptionScope: $ config ->get ("encryption_scope " ),
275+ ipRange: $ config ->get ("ip_range " ),
276+ snapshotTime: $ config ->get ("snapshot_time " ),
277+ protocol: $ config ->get ("protocol " , SASProtocol::HTTPS_AND_HTTP ),
278+ version: $ config ->get ("version " ),
294279 );
295280
296- $ sas = SharedAccessSignatureHelper::generateBlobSASQueryParameters (
297- $ sasValues ,
298- $ this ->containerClient ->sharedKeyCredentials ,
299- );
281+ $ sas = BlobSASQueryParameters::generate ($ values , $ this ->containerClient ->sharedKeyCredentials );
300282
301283 return sprintf ("%s?%s " , $ url , $ sas );
302284 }
303-
304- public function temporaryUrl (string $ path , DateTimeInterface $ expiresAt , Config $ config ): string
305- {
306- $ config ->withSetting ("expires_on " , $ expiresAt );
307-
308- return $ this ->publicUrl ($ path , $ config );
309- }
310285}
0 commit comments