File tree Expand file tree Collapse file tree 2 files changed +43
-12
lines changed
Expand file tree Collapse file tree 2 files changed +43
-12
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace AzureOss \LaravelAzureStorageBlob ;
4+
5+ use AzureOss \FlysystemAzureBlobStorage \AzureBlobStorageAdapter ;
6+ use AzureOss \Storage \Blob \BlobServiceClient ;
7+ use Illuminate \Filesystem \FilesystemAdapter ;
8+ use League \Flysystem \Config ;
9+ use League \Flysystem \Filesystem ;
10+
11+ /**
12+ * @internal
13+ */
14+ final class AzureStorageBlobAdapter extends FilesystemAdapter
15+ {
16+ public function __construct (array $ config )
17+ {
18+ $ serviceClient = BlobServiceClient::fromConnectionString ($ config ['connection_string ' ]);
19+ $ containerClient = $ serviceClient ->getContainerClient ($ config ['container ' ]);
20+ $ adapter = new AzureBlobStorageAdapter ($ containerClient , $ config ['prefix ' ] ?? "" );
21+
22+ parent ::__construct (
23+ new Filesystem ($ adapter , $ config ),
24+ $ adapter ,
25+ $ config
26+ );
27+ }
28+
29+ public function temporaryUrl ($ path , $ expiration , array $ options = [])
30+ {
31+ $ options ["permissions " ] = $ options ["permissions " ] ?? "r " ;
32+
33+ return $ this ->adapter ->temporaryUrl ($ path , $ expiration , new Config ($ options ));
34+ }
35+
36+ public function temporaryUploadUrl ($ path , $ expiration , array $ options = [])
37+ {
38+ $ options ["permissions " ] = $ options ["permissions " ] ?? "w " ;
39+
40+ return $ this ->adapter ->temporaryUrl ($ path , $ expiration , new Config ($ options ));
41+ }
42+ }
Original file line number Diff line number Diff line change 22
33namespace AzureOss \LaravelAzureStorageBlob ;
44
5- use AzureOss \FlysystemAzureBlobStorage \AzureBlobStorageAdapter ;
6- use AzureOss \Storage \Blob \BlobServiceClient ;
75use Illuminate \Contracts \Foundation \Application ;
86use Illuminate \Filesystem \FilesystemAdapter ;
97use Illuminate \Support \Facades \Storage ;
108use Illuminate \Support \ServiceProvider ;
11- use League \Flysystem \Filesystem ;
129
1310/**
1411 * @internal
@@ -18,15 +15,7 @@ final class AzureStorageBlobServiceProvider extends ServiceProvider
1815 public function boot (): void
1916 {
2017 Storage::extend ('azure-storage-blob ' , function (Application $ app , array $ config ): FilesystemAdapter {
21- $ serviceClient = BlobServiceClient::fromConnectionString ($ config ['connection_string ' ]);
22- $ containerClient = $ serviceClient ->getContainerClient ($ config ['container ' ]);
23- $ adapter = new AzureBlobStorageAdapter ($ containerClient , $ config ['prefix ' ] ?? "" );
24-
25- return new FilesystemAdapter (
26- new Filesystem ($ adapter , $ config ),
27- $ adapter ,
28- $ config
29- );
18+ return new AzureStorageBlobAdapter ($ config );
3019 });
3120 }
3221}
You can’t perform that action at this time.
0 commit comments