public async Task UploadFile()

in src/AIHub/Controllers/ContentSafetyController.cs [228:270]


    public async Task<IActionResult> UploadFile(IFormFile imageFile)
    {
        // Check if the file is null
        if (imageFile == null || imageFile.Length == 0)
        {
            ViewBag.Message = "You must select an image to upload";
            return View("ImageModerator", model);
        }
        // Check if the file is an image
        if (!imageFile.ContentType.Contains("image"))
        {
            ViewBag.Message = "You must select an image to upload";
            return View("ImageModerator", model);
        }
        // check if the file is too big
        if (imageFile.Length > 3000000)
        {
            ViewBag.Message = "The image is too big. File must be less than 3MB";
            return View("ImageModerator", model);
        }
        // Check if the threshold values are null
        if (CheckNullValues(HttpContext))
        {
            ViewBag.Message = "You must enter a value for each threshold";
            return View("ImageModerator", model);
        }
        model.Severity = Convert.ToInt32(HttpContext.Request.Form["severitytext"]);
        model.Violence = Convert.ToInt32(HttpContext.Request.Form["violencetext"]);
        model.SelfHarm = Convert.ToInt32(HttpContext.Request.Form["shtext"]);
        model.Hate = Convert.ToInt32(HttpContext.Request.Form["hatetext"]);

        // Upload file to azure storage account
        BlobClient blobClient = containerClient.GetBlobClient(imageFile.FileName);
        await blobClient.UploadAsync(imageFile.OpenReadStream(), true);

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

        // Call EvaluateImage with the url
        EvaluateImage(blobUrl.ToString());

        return Ok(model);
    }