[HttpPost("UploadifyFile")]
[RequestSizeLimit(2000 * 1024 * 1024)]
public async Task<IActionResult> UploadifyFile(IFormFile file)
{
try
{
var filePath = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\attachments", file.FileName);
string extractPath = Directory.GetCurrentDirectory() + @"\wwwroot\attachments";
if (!System.IO.File.Exists(filePath))
{
await SaveFileAsync(file, filePath);
ExtractArchive(filePath, extractPath);
System.IO.File.Delete(filePath);
}
return Ok(filePath);
}
catch (Exception ex)
{
_logger.LogError(ex, "An error occurred during file upload.");
return Ok(ex.Message);
}
}
var builder = WebApplication.CreateBuilder(args);
builder.Services.Configure<FormOptions>(options =>
{
options.MultipartBodyLengthLimit = int.MaxValue;
options.ValueCountLimit = int.MaxValue;
options.ValueLengthLimit = int.MaxValue;
});
builder.Services.Configure<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize = int.MaxValue;
});
builder.Services.Configure<IISServerOptions>(options =>
{
options.MaxRequestBodySize = int.MaxValue;
});