Skip to content

Commit 7a08579

Browse files
committed
ContentType默认赋值
1 parent 6f8a08f commit 7a08579

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

WebApiClientCore/HttpContents/FormDataFileContent.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ namespace WebApiClientCore.HttpContents
99
/// </summary>
1010
public class FormDataFileContent : StreamContent, ICustomHttpContentConvertable
1111
{
12+
/// <summary>
13+
/// application/octet-stream
14+
/// </summary>
15+
public static string OctetStream => "application/octet-stream";
16+
1217
/// <summary>
1318
/// form-data文件内容
1419
/// </summary>
@@ -31,7 +36,7 @@ public FormDataFileContent(Stream stream, string name, string? fileName, string?
3136

3237
if (string.IsNullOrEmpty(contentType) == true)
3338
{
34-
contentType = "application/octet-stream";
39+
contentType = OctetStream;
3540
}
3641
this.Headers.ContentType = new MediaTypeHeaderValue(contentType);
3742
}

WebApiClientCore/Parameters/FormDataFile.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text;
66
using System.Threading;
77
using System.Threading.Tasks;
8+
using WebApiClientCore.HttpContents;
89
using WebApiClientCore.Internals;
910

1011
namespace WebApiClientCore.Parameters
@@ -28,7 +29,7 @@ public class FormDataFile : IApiParameter
2829
/// <summary>
2930
/// 获取或设置文件的Mime
3031
/// </summary>
31-
public string? ContentType { get; set; }
32+
public string? ContentType { get; set; } = FormDataFileContent.OctetStream;
3233

3334
/// <summary>
3435
/// 获取编码后的文件好友名称

0 commit comments

Comments
 (0)