Exemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            // Upload the new clip as a blob
            string name = Guid.NewGuid().ToString();

            #region v11 UploadFromStreamAsync

            /*
             * CloudBlockBlob blob = ClipsBlobService.GetContainerReference(UserId).GetBlockBlobReference(name);
             * using (var stream = GetNewClipAsStream())
             * {
             *  await blob.UploadFromStreamAsync(stream);
             * }
             * /**/
            #endregion

            #region v12 UploadAsync
            BlobClient blob = ClipsBlobService.GetBlobContainerClient(UserId).GetBlobClient(name);
            using (var stream = GetNewClipAsStream())
            {
                await blob.UploadAsync(stream);
            }
            #endregion

            // Navigate to that page
            return(RedirectToPage("Clip", new { userId = this.UserId, clipId = name }));
        }
Exemplo n.º 2
0
        public async Task OnGetAsync()
        {
            #region v11 ListBlobsSegmentedAsync

            /*
             * CloudBlobClient blobService = (CloudBlobClient)HttpContext.RequestServices.GetService(typeof(CloudBlobClient));
             * CloudBlobContainer userContainerReference = blobService.GetContainerReference(UserId);
             * BlobContinuationToken continuation = null;
             * do
             * {
             *  BlobResultSegment segment = await userContainerReference.ListBlobsSegmentedAsync(null, continuation);
             *  continuation = segment.ContinuationToken;
             *  foreach (IListBlobItem clipBlobItem in segment.Results)
             *  {
             *      ClipIds.Add(new BlobUriBuilder(clipBlobItem.Uri).BlobName);
             *  }
             * } while (continuation != null);
             * /**/
            #endregion

            #region v12 GetBlobsAsync
            BlobContainerClient userContainer = ClipsBlobService.GetBlobContainerClient(UserId);
            await foreach (BlobItem clipBlob in userContainer.GetBlobsAsync())
            {
                ClipIds.Add(clipBlob.Name);
            }
            #endregion
        }