日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Azure blob 文件下载

發(fā)布時間:2024/3/26 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Azure blob 文件下载 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1、獲取所有Azure 容器中的資源文件

private string azureConnectionStrig = " DefaultEndpointsProtocol = https; AccountName =" + storageConfig.AccountName + " ; AccountKey =" + storageConfig.AccesssKey; private string AccountName =storageConfig.AccountName;private CloudStorageAccount _storageAccount;private CloudBlobContainer _cloudBlobContainer; public async Task<List<string>> GetResourceURL() {BlobContinuationToken blobContinuationToken = null;List<string> resourceURI = new List<string>();do{if (await TryGetRemote()){var results = await _cloudBlobContainer.ListBlobsSegmentedAsync(null, blobContinuationToken);blobContinuationToken = results.ContinuationToken;foreach (IListBlobItem item in results.Results){resourceURI.Add(item.Uri.ToString());}}} while (blobContinuationToken != null); return resourceURI; } public async Task<bool> TryGetRemote(){if (CloudStorageAccount.TryParse(azureConnectionStrig, out _storageAccount)){CloudBlobClient cloudBlobClient = _storageAccount.CreateCloudBlobClient();try{_cloudBlobContainer = cloudBlobClient.GetContainerReference(AccountName);BlobContainerPermissions permissions = new BlobContainerPermissions{PublicAccess = BlobContainerPublicAccessType.Blob};Task task = _cloudBlobContainer.SetPermissionsAsync(permissions);//超時1秒if ((await Task.WhenAny(task, Task.Delay(TimeSpan.FromSeconds(1)))) != task){Console.Write("連接服務器超時");return false;} return true;}catch (WebException e){Console.Write("更新服務器連接失敗" + e.ToString());}catch (Exception e){Console.Write("初始化azureblob失敗" + e.ToString());}}return false;}

2、獲正確的支援文件

?2.1? 定義文件屬性

public interface IFile{bool IsCorrectName();int GetVersion();void Clean();string GetName();}

2.2獲取文件

2、獲取資源文件跟進行比對

private Dictionary<string, T> GetRemoteNewerFile(List<T> azureFiles){Dictionary<string, T> matches = new Dictionary<string, T>();foreach (var azureFile in azureFiles){if (matches.ContainsKey(azureFile.GetName())){if (matches[azureFile.GetName()].GetVersion() < azureFile.GetVersion()){matches[azureFile.GetName()] = azureFile;}}else{matches.Add(azureFile.GetName(), azureFile);}}return matches;}

...........待續(xù)

總結

以上是生活随笔為你收集整理的Azure blob 文件下载的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。