1- using Microsoft . WindowsAzure . Storage ;
2- using Microsoft . WindowsAzure . Storage . Blob ;
3- using System ;
4- using System . Collections . Generic ;
5- using System . IO ;
6- using System . Linq ;
7- using System . Threading . Tasks ;
8-
9- namespace GeekLearning . Storage . Azure
1+ namespace GeekLearning . Storage . Azure
102{
3+ using Microsoft . WindowsAzure . Storage ;
4+ using Microsoft . WindowsAzure . Storage . Blob ;
5+ using System ;
6+ using System . Collections . Generic ;
7+ using System . IO ;
8+ using System . Linq ;
9+ using System . Threading . Tasks ;
10+
1111 public class AzureStore : IStore
1212 {
1313 private string connectionString ;
1414 private Lazy < CloudBlobContainer > container ;
1515 private Lazy < CloudBlobClient > client ;
1616 private string containerName ;
1717
18-
1918 public AzureStore ( string connectionString , string containerName )
2019 {
2120 if ( string . IsNullOrWhiteSpace ( connectionString ) )
@@ -54,13 +53,13 @@ private Task<ICloudBlob> GetBlobReference(string path)
5453 if ( uri . IsAbsoluteUri )
5554 {
5655 return this . client . Value . GetBlobReferenceFromServerAsync ( uri ) ;
57- } else
56+ }
57+ else
5858 {
5959 return this . container . Value . GetBlobReferenceFromServerAsync ( path ) ;
6060 }
6161 }
6262
63-
6463 public async Task < Stream > Read ( string path )
6564 {
6665 return await this . ReadInMemory ( path ) ;
@@ -78,7 +77,7 @@ public async Task<string> ReadAllText(string path)
7877 using ( var reader = new StreamReader ( await blockBlob . OpenReadAsync ( AccessCondition . GenerateEmptyCondition ( ) , new BlobRequestOptions ( ) , new OperationContext ( ) ) ) )
7978 {
8079 return await reader . ReadToEndAsync ( ) ;
81- } ;
80+ }
8281 }
8382
8483 public async Task < string > Save ( Stream data , string path , string mimeType )
@@ -103,6 +102,11 @@ public async Task<string> Save(byte[] data, string path, string mimeType)
103102
104103 public async Task < string [ ] > List ( string path )
105104 {
105+ if ( path . EndsWith ( "*" ) )
106+ {
107+ path = path . TrimEnd ( '*' ) ;
108+ }
109+
106110 BlobContinuationToken continuationToken = null ;
107111 List < IListBlobItem > results = new List < IListBlobItem > ( ) ;
108112 do
@@ -112,6 +116,7 @@ public async Task<string[]> List(string path)
112116 results . AddRange ( response . Results ) ;
113117 }
114118 while ( continuationToken != null ) ;
119+
115120 return results . Select ( blob => blob . Uri . ToString ( ) ) . ToArray ( ) ;
116121 }
117122
0 commit comments