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.
Did you know that with WEBCON you can automate virtually any process? Even baking cookies 🍪
 
Speaking of cookies: we use the ones that are essential for our website to function properly, as well as additional ones that help us customize our content to your preferences. If you don’t mind cookies, click Accept. If you want to learn more, explore settings.
Settings