【问题标题】:Using Flurl to send a list of files to an asp.net core's IFormFileCollection使用 Flurl 将文件列表发送到 asp.net 核心的 IFormFileCollection
【发布时间】:2021-09-07 00:43:22
【问题描述】:

我有一个这样定义的端点:

[HttpPost]
public async Task<ActionResult> Post( ... [FromForm] IFormFileCollection images) { }

使用 PostMultipartAsync 发布对于单个流效果很好,但我如何将它用于流列表?

【问题讨论】:

    标签: asp.net-core flurl


    【解决方案1】:

    你说的是流列表的上传部分吗?有一个example来自

    这个问题,基本上说明了所有的可能性:

    var resp = await "http://api.com"
        .PostMultipartAsync(mp => mp
            .AddString("name", "hello!")                // individual string
            .AddStringParts(new {a = 1, b = 2})         // multiple strings
            .AddFile("file1", path1)                    // local file path
            .AddFile("file2", stream, "foo.txt")        // file stream
            .AddJson("json", new { foo = "x" })         // json
            .AddUrlEncoded("urlEnc", new { bar = "y" }) // URL-encoded                      
            .Add(content));                             // any HttpContent
    

    官方文档:https://flurl.dev/docs/fluent-url/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2022-11-04
      • 1970-01-01
      • 2019-09-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多