I'm getting the following error when uploading a file via my .NET Core application hosted as an Azure Web App:
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
This was tested in Postman and timed out with a 404 Not Found at around 22 seconds.
My application code is as follows, stripping out the extra stuff:
public async Task<IActionResult> PostDocuments(ICollection<IFormFile> files)
{
foreach (var file in files)
{
string path = Path.Combine(uploadsDir, file.FileName);
//Uploading file to "uploads" to be staged. Doesn't get past here.
using (var stream = new FileStream(Path.Combine(uploadsDir, file.FileName), FileMode.Create))
{
await file.CopyToAsync(stream);
}
//Uploading files to Azure
if (await _azure.UploadFile(path, file.FileName)
{
// Stuff to add file to database
}
else
{
return StatusCode(400, "Could not upload one or all of your files.");
}
}
else
{
return StatusCode(400, "One or all of your files are empty, have invalid types, or are targeting mismatched buildings or floors.");
}
}
return StatusCode(201, files);
}
I believe my issue is simply that the request is taking too long and Azure is cancelling it to maintain the integrity of the application. It also sounds like from my research that maybe I need to allow the application to start the Azure upload and move onto adding it to the database. However, from my testing locally, it appears the long part of the process is even before I get to any of my controller's logic. Is there a better way to do this?