Example #1
0
        //=================download=============================
        //https://docs.microsoft.com/en-us/azure/visual-studio/vs-storage-aspnet-core-getting-started-blobs
        public ActionResult ListBlobs()
        {
            BlobManager        bm            = new BlobManager();
            CloudBlobContainer container     = bm.GetContainer("mysamplecontainer");
            List <string>      blobs         = new List <string>();
            BlobResultSegment  resultSegment = container.ListBlobsSegmentedAsync(null).Result;

            foreach (IListBlobItem item in resultSegment.Results)
            {
                if (item.GetType() == typeof(CloudBlockBlob))
                {
                    CloudBlockBlob blob = (CloudBlockBlob)item;
                    blobs.Add(blob.Name);
                }
                else if (item.GetType() == typeof(CloudPageBlob))
                {
                    CloudPageBlob blob = (CloudPageBlob)item;
                    blobs.Add(blob.Name);
                }
                else if (item.GetType() == typeof(CloudBlobDirectory))
                {
                    CloudBlobDirectory dir = (CloudBlobDirectory)item;
                    blobs.Add(dir.Uri.ToString());
                }
            }

            return(View(blobs));
        }
Example #2
0
        public ActionResult CreateBlobContainer()
        {
            BlobManager        bm        = new BlobManager();
            CloudBlobContainer container = bm.GetContainer("mysamplecontainer");

            ViewBag.Success           = container.CreateIfNotExistsAsync().Result;
            ViewBag.BlobContainerName = container.Name;
            return(View());
        }