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<ActionResult<GoogleFile>> 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<string> ParentIds { get; set; }


public IFormFile File { get; set; }
}

Nobody has replied in this thread yet.