Home > Forum > Forms > Fileupload failing

Fileupload failing
0

I need to upload attachments to our company cloud services. Below is the web api endpoint that accept a file:
[HttpPost("createfilewithcontent"), DisableRequestSizeLimit]
public async Task> CreateFileWithContent([FromForm] GFileWithContentWrite fileInfo)
{
var stream = fileInfo.File.OpenReadStream();
var createdFile = await _driveService.CreateFileAsync(
new GoogleFileWrite() { Description= fileInfo.Description, MimeType = fileInfo.MimeType, Name = fileInfo.Name, ParentIds = fileInfo.ParentIds },
stream);
return Ok(createdFile);
}

The process always fail since the fileInfo.File is always null. Below is the definition of the object

public class GFileWithContentWrite
{
public string Name { get; set; }

public string MimeType { get; set; }


public IList ParentIds { get; set; }


public IFormFile File { get; set; }
}

Nobody has replied in this thread yet.

Privacy overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognizing you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.


To see a full list of the cookies we use and learn more about their purposes, visit our Privacy Policy.