Skip to content

Commit 6f8a08f

Browse files
committed
2 parents d130475 + 3a7bec0 commit 6f8a08f

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

App/Clients/UserService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public async Task RunRequestAsync()
2626
};
2727

2828
// 上传的文件
29-
var file = new FormDataFile("TextFile.txt");
29+
var file = new FormDataFile("文件TextFile.txt");
3030

3131
var response = await userApi.GetAsync(account: "get1");
3232

App/文件TextFile.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
这是上传的文件内容

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>2.0.0</Version>
3+
<Version>2.0.1-preview1</Version>
44
<Copyright>Copyright © laojiu 2017-2021</Copyright>
55
<NoWarn>IDE0057</NoWarn>
66
</PropertyGroup>

WebApiClientCore/Parameters/FormDataFile.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.ComponentModel;
23
using System.Diagnostics;
34
using System.IO;
45
using System.Text;
@@ -32,6 +33,8 @@ public class FormDataFile : IApiParameter
3233
/// <summary>
3334
/// 获取编码后的文件好友名称
3435
/// </summary>
36+
[EditorBrowsable(EditorBrowsableState.Never)]
37+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
3538
public virtual string? EncodedFileName => HttpUtil.UrlEncode(this.FileName, Encoding.UTF8);
3639

3740
/// <summary>
@@ -95,7 +98,7 @@ public FormDataFile(Func<Stream> streamFactory, string? fileName)
9598
public Task OnRequestAsync(ApiParameterContext context)
9699
{
97100
var stream = this.streamFactory();
98-
context.HttpContext.RequestMessage.AddFormDataFile(stream, context.ParameterName, this.EncodedFileName, this.ContentType);
101+
context.HttpContext.RequestMessage.AddFormDataFile(stream, context.ParameterName, this.FileName, this.ContentType);
99102
return Task.CompletedTask;
100103
}
101104

0 commit comments

Comments
 (0)