【发布时间】:2021-09-23 19:37:17
【问题描述】:
不幸的是,我一直无法让我的 api 工作并遇到一些奇怪的行为。为了与一些卫星数据一起发布文件,它的工作原理如下:
使用以下模型:
public class SomeDTO
{
public int Id { get; set; }
public string Title { get; set; }
public string Category { get; set; }
public IFormFileCollection Files { get; set; }
}
现在,我创建了一个嵌套对象并将Files 属性移动到该对象中,如下所示:
public class FilesUploadDTO
{
public IEnumerable<string> Remote { get; set; }
public IFormFileCollection Local { get; set; }
}
public class SomeDTO
{
public int Id { get; set; }
public string Title { get; set; }
public string Category { get; set; }
public FilesUploadDTO Files { get; set; }
}
这是我在 Postman 的截图。除了始终为空的Files.Local 之外,所有内容都会发布:
【问题讨论】:
标签: asp.net asp.net-core asp.net-web-api