控制器:
[HttpPost("CreateEmail")]
[Consumes("multipart/form-data")]
public async Task<ApiResponse<Guid>> PostEmailToProcess([FromForm]EmailToProcess email)
{
try
{
var emailToAdd = new EmailToProcessDto(email);
emailToAdd.Created = DateTime.Now;
var emailId = await _emailRepository.PostEmailAsync(emailToAdd);
foreach (var file in email)
{
if (email.IFormFile != null)
{
await _contentUploadService.Upload(file, emailId.Data);
}
}
// etc
通过电子邮件发送到进程对象:
public class EmailToProcess
{
public string From { get; set; }
public string To { get; set; }
...
public IFormFile[] IFormFile { get; set; }
}
当我发布EmailToProcess时-所有字段返回正确的数据,但IFormFile属性中的数据始终为空。当我允许它只提交1个IFormFile(无数组)时-它工作正常,没有空值
1条答案
按热度按时间hts6caw31#
你可以看看this的例子。