© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
12 replies
Alex

Upload file with swagger ui crash

I'm trying to upload IFormFIle with swagger ui and as soon as I select file and click select or cancel the backend application crashes without any error displayed. Can I fix it? Is it better to switch to Postman?
[HttpPost("upload")]
public async Task<IActionResult> Upload(IFormFile? formFile)
{
    if (formFile == null || formFile.Length == 0)
    {
        return BadRequest("No file uploaded.");
    }

    var putObjectArgs = new PutObjectArgs()
        .WithBucket(_config.BucketName)
        .WithObject(formFile.FileName)
        .WithObjectSize(formFile.Length)
        .WithContentType(formFile.ContentType)
        .WithStreamData(formFile.OpenReadStream());
    
    // TODO: check if object is uploaded to the bucket
    await _minio.PutObjectAsync(putObjectArgs);

    return Ok(new {message = "File uploaded to the bucket"});
}
[HttpPost("upload")]
public async Task<IActionResult> Upload(IFormFile? formFile)
{
    if (formFile == null || formFile.Length == 0)
    {
        return BadRequest("No file uploaded.");
    }

    var putObjectArgs = new PutObjectArgs()
        .WithBucket(_config.BucketName)
        .WithObject(formFile.FileName)
        .WithObjectSize(formFile.Length)
        .WithContentType(formFile.ContentType)
        .WithStreamData(formFile.OpenReadStream());
    
    // TODO: check if object is uploaded to the bucket
    await _minio.PutObjectAsync(putObjectArgs);

    return Ok(new {message = "File uploaded to the bucket"});
}
image.png
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Configure Swagger UI through docker?
C#CC# / help
12mo ago
✅ Swashbuckle to other swagger UI
C#CC# / help
15mo ago
❔ Ocelot with Swagger
C#CC# / help
3y ago
Swagger UI breaks due to API versioning.
C#CC# / help
7mo ago