File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
storage_blobs/src/clients Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -68,12 +68,10 @@ impl TryFrom<&Url> for CloudLocation {
6868 // TODO: This only works for Public and China clouds.
6969 // ref: https://github.com/Azure/azure-sdk-for-rust/issues/502
7070 fn try_from ( url : & Url ) -> azure_core:: Result < Self > {
71- let token = url. query ( ) . ok_or_else ( || {
72- azure_core:: Error :: with_message ( azure_core:: error:: ErrorKind :: DataConversion , || {
73- "unable to find SAS token in URL"
74- } )
75- } ) ?;
76- let credentials = StorageCredentials :: sas_token ( token) ?;
71+ let credentials = match url. query ( ) {
72+ Some ( token) => StorageCredentials :: sas_token ( token) ?,
73+ None => StorageCredentials :: Anonymous ,
74+ } ;
7775
7876 let host = url. host_str ( ) . ok_or_else ( || {
7977 azure_core:: Error :: with_message ( azure_core:: error:: ErrorKind :: DataConversion , || {
Original file line number Diff line number Diff line change @@ -345,7 +345,9 @@ mod tests {
345345 assert ! ( matches!( creds, StorageCredentials :: SASToken ( _) ) ) ;
346346
347347 let url = Url :: parse ( "https://accountname.blob.core.windows.net/mycontainer/myblob" ) ?;
348- assert ! ( BlobClient :: from_sas_url( & url) . is_err( ) , "missing token" ) ;
348+ let blob_client = BlobClient :: from_sas_url ( & url) ?;
349+ let creds = blob_client. container_client . credentials ( ) ;
350+ assert ! ( matches!( creds, StorageCredentials :: Anonymous ) ) ;
349351
350352 let url = Url :: parse ( "https://accountname.blob.core.windows.net/mycontainer?token=1" ) ?;
351353 assert ! ( BlobClient :: from_sas_url( & url) . is_err( ) , "missing path" ) ;
You can’t perform that action at this time.
0 commit comments