Exemplo n.º 1
0
        public async Task <IActionResult> UploadNewScreenshot(IFormFile file, string tags, string title, int gameId)
        {
            var container = _screenshotService.GetBlobContainer(AzureConnectionString, "screenshots");

            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 _screenshotService.SetScreenshot(title, gameId, tags, blockBlob.Uri);

            return(RedirectToAction("Index", "ScreenshotGallery", new { id = gameId }));
        }