Example #1
0
        /// <summary>
        /// Blob List
        /// ルートのみ
        /// </summary>
        /// <returns></returns>
        public async Task <List <BlobListDataModel> > BlobGetListAsync(string containerName)
        {
            // 一覧確保
            List <BlobListDataModel> models = new List <BlobListDataModel>();

            var container = blobClient.GetContainerReference(containerName);
            BlobContinuationToken blobtoken = null;

            do
            {
                var blobResult = await container.ListBlobsSegmentedAsync(blobtoken);

                // 継続トークンの取得
                blobtoken = blobResult.ContinuationToken;

                // 取得情報をList取得
                var blobList = blobResult.Results.ToList();

                foreach (var item in blobList)
                {
                    var blobListDataModel = new BlobListDataModel();

                    var blobTypeName = item.GetType().ToString().Split('.').Last();

                    if (item is CloudBlobDirectory)
                    {
                        // 取得はディレクトリ
                        blobListDataModel.name         = ((CloudBlobDirectory)item).Prefix.Trim('/');
                        blobListDataModel.contentType  = "Folder";
                        blobListDataModel.blobType     = blobTypeName;
                        blobListDataModel.size         = null;
                        blobListDataModel.lastModified = null;

                        models.Add(blobListDataModel);
                    }
                    else if (item is CloudPageBlob)
                    {
                        // 取得はPage
                        // 未実装
                    }
                    else if (item is CloudBlockBlob)
                    {
                        // 取得はBlock
                        blobListDataModel.name         = ((CloudBlockBlob)item).Name;
                        blobListDataModel.contentType  = ((CloudBlockBlob)item).Properties.ContentType;
                        blobListDataModel.blobType     = blobTypeName;
                        blobListDataModel.size         = ((CloudBlockBlob)item).Properties.Length;
                        blobListDataModel.lastModified = ((CloudBlockBlob)item).Properties.LastModified.Value.DateTime;

                        models.Add(blobListDataModel);
                    }
                    else
                    {
                        // 不明
                    }
                }
            } while (blobtoken != null);

            return(models);
        }
Example #2
0
 /// <summary>
 /// アイテム選択
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void listView_ItemClick(object sender, ItemClickEventArgs e)
 {
     selectBlobData = (BlobListDataModel)e.ClickedItem;
 }