File tree 2 files changed +31
-2
lines changed
2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 22
22
ResourceExistsError ,
23
23
ResourceNotFoundError ,
24
24
)
25
+ from azure .core .utils import parse_connection_string
25
26
from azure .storage .blob import (
26
27
BlobBlock ,
27
28
BlobProperties ,
@@ -1550,11 +1551,19 @@ async def _url(
1550
1551
"""
1551
1552
container_name , blob , version_id = self .split_path (path )
1552
1553
1554
+ if self .connection_string :
1555
+ args_dict = parse_connection_string (self .connection_string )
1556
+ account_name = args_dict .get ("accountname" )
1557
+ account_key = args_dict .get ("accountkey" )
1558
+ else :
1559
+ account_name = self .account_name
1560
+ account_key = self .account_key
1561
+
1553
1562
sas_token = generate_blob_sas (
1554
- account_name = self . account_name ,
1563
+ account_name = account_name ,
1555
1564
container_name = container_name ,
1556
1565
blob_name = blob ,
1557
- account_key = self . account_key ,
1566
+ account_key = account_key ,
1558
1567
permission = BlobSasPermissions (read = True ),
1559
1568
expiry = datetime .utcnow () + timedelta (seconds = expires ),
1560
1569
version_id = version_id ,
Original file line number Diff line number Diff line change @@ -1629,6 +1629,26 @@ async def test_url_versioned(storage, mocker):
1629
1629
)
1630
1630
1631
1631
1632
+ async def test_url_with_conn_str (mocker ):
1633
+ fs = AzureBlobFileSystem (connection_string = CONN_STR )
1634
+ generate_blob_sas = mocker .patch ("adlfs.spec.generate_blob_sas" )
1635
+
1636
+ await fs ._url ("data/root/a/file.txt" )
1637
+ generate_blob_sas .assert_called_once_with (
1638
+ account_name = ACCOUNT_NAME ,
1639
+ container_name = "data" ,
1640
+ blob_name = "root/a/file.txt" ,
1641
+ account_key = KEY ,
1642
+ permission = mocker .ANY ,
1643
+ expiry = mocker .ANY ,
1644
+ version_id = None ,
1645
+ content_disposition = None ,
1646
+ content_encoding = None ,
1647
+ content_language = None ,
1648
+ content_type = None ,
1649
+ )
1650
+
1651
+
1632
1652
def test_cp_file (storage ):
1633
1653
fs = AzureBlobFileSystem (
1634
1654
account_name = storage .account_name , connection_string = CONN_STR
You can’t perform that action at this time.
0 commit comments