public async Task UploadFile()

in src/AIHub/Controllers/ImageAnalyzerController.cs [116:152]


    public async Task<IActionResult> UploadFile(IFormFile imageFile)
    {
        // Check no image
        if (CheckNullValues(imageFile))
        {
            ViewBag.Message = "You must upload an image";
            return View("ImageAnalyzer");
        }
        if (string.IsNullOrEmpty(HttpContext.Request.Form["text"]))
        {
            ViewBag.Message = "You must enter a prompt to evaluate";
            return View("ImageAnalyzer", model);
        }
        model.Prompt = HttpContext.Request.Form["text"];
        // Upload file to azure storage account
        string url = imageFile.FileName.ToString();
        Console.WriteLine(url);

        BlobClient blobClient = containerClient.GetBlobClient(url);
        await blobClient.UploadAsync(imageFile.OpenReadStream(), true);

        // Get the url of the file
        Uri blobUrl = blobClient.Uri;

        if (CheckImageExtension(blobUrl.ToString()))
        {
            ViewBag.Message = "You must upload an image with .jpg, .jpeg or .png extension";
            return View("ImageAnalyzer");
        }

        // Call EvaluateImage with the url
        Console.WriteLine(blobUrl.ToString());
        await DenseCaptionImage(blobUrl.ToString(), model.Prompt!);
        ViewBag.Waiting = null;

        return Ok(model);
    }