예제 #1
0
        public async Task <IActionResult> AddNewGame(IFormFile file, string title, string genre, string platform,
                                                     int releaseYear)
        {
            var container = _gamesService.GetBlobContainer(AzureConnectionString, "games");

            var content =
                ContentDispositionHeaderValue.Parse(file
                                                    .ContentDisposition); //TO DO: error handling in case of null object reference

            var fileName = content.FileName.Trim('"');

            var blockBlob = container.GetBlockBlobReference(fileName);

            await blockBlob.UploadFromStreamAsync(file.OpenReadStream());

            await _gamesService.SetGame(title, genre, platform, releaseYear, blockBlob.Uri);

            return(RedirectToAction("Index", "Catalog"));
        }