in src/AIHub/Controllers/FormAnalyzerController.cs [87:122]
public async Task<IActionResult> UploadFile(IFormFile imageFile, string prompt)
{
// Check no image
if (CheckNullValues(imageFile))
{
ViewBag.Message = "You must upload an image";
return View("FormAnalyzer");
}
// Upload file to azure storage account
string url = imageFile.FileName.ToString();
Console.WriteLine(url);
url = url.Replace(" ", "");
Console.WriteLine(url);
BlobClient blobClient = containerClient.GetBlobClient(url);
var httpHeaders = new BlobHttpHeaders
{
ContentType = "application/pdf",
};
await blobClient.UploadAsync(imageFile.OpenReadStream(), new BlobUploadOptions { HttpHeaders = httpHeaders });
// Get the url of the file
Uri blobUrl = blobClient.Uri;
if (CheckImageExtension(blobUrl.ToString()))
{
ViewBag.Message = "You must upload a document with .pdf extension";
return View("FormAnalyzer", model);
}
// Call EvaluateImage with the url
await AnalyzeForm(blobUrl.ToString(), prompt);
ViewBag.Waiting = null;
return Ok(model);
}