【问题标题】:Asp.Net Post Nested List of FilesAsp.Net 发布嵌套文件列表
【发布时间】: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


    【解决方案1】:

    你可以改用files.local,这是我的测试结果:

    This section提醒我这样写。

    【讨论】:

    • 你说得对,那行得通。感谢您的意见。
    猜你喜欢
    • 2020-12-03
    • 1970-01-01
    • 2016-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多