這是我的控制器動作:
// POST: api/Customers/Create
[HttpPost(), Route("Create")]
public async Task<ActionResult> CreateAsync([FromForm] CustomerModel model)
它收到一個CustomerModel:
public Guid? Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string PhoneNumber { get; set; }
public string Email { get; set; }
public bool? IsActive { get; set; }
public List<CustomerLicenseModel> LicenseFiles { get; set; }
我CustomerModel有一個自定義類,它是型別檔案的串列CustomerLicenseModel
public List<CustomerLicenseModel> LicenseFiles { get; set; }
這是CustomerLicenseModel:
public class CustomerLicenseModel
{
public LicenseFileType LicenseFileType { get; set; }
public IFormFile LicenseFile { get; set; }
}
LicenseFileType可以是正面或背面。
public enum LicenseFileType
{
Front,
Back
}
如何通過 http 請求發送這個?
如果我的List<IFormFile>內部有一個CustomerModel,例如,我可以通過郵遞員或 swagger 發送多個檔案,但我需要知道它LicenseFileType是什么。
有人可以幫忙嗎?
uj5u.com熱心網友回復:
Swagger 默認不支持這種格式的傳輸,所以建議你使用postman發送requset。


轉載請註明出處,本文鏈接:https://www.uj5u.com/net/431757.html
標籤:asp.net 核心 asp.net-web-api iform 文件
