参考博文地址 
https://www.cnblogs.com/cplemom/p/11264040.html
https://www.cnblogs.com/netcs/p/12789162.html
  var client = _httpClientFactory.CreateClient();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue($"multipart/form-data"));
                var content = new MultipartFormDataContent();
                content.Add(new StringContent(type), "type");
                byte[] arr;
                using (Stream fileStream = file.OpenReadStream())
                {
                    arr = new byte[fileStream.Length];
                    fileStream.Read(arr, 0, arr.Length);
                }
                var upFileContent = new ByteArrayContent(arr);
                upFileContent.Headers.ContentType = new MediaTypeHeaderValue(file.ContentType);
                content.Add(upFileContent, "file", file.FileName);
                var reponse = await client.PostAsync("ip地址/api/FileUpload/ImageUpload", content);

  主要还是橙色代码块 设置文件ContentType

不设置这个 接口端File.ContentType是接收不到类型的

相关文章:

  • 2022-12-23
  • 2021-06-04
  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
猜你喜欢
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2021-11-22
相关资源
相似解决方案