File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed
WebApiClient/Parameterables Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Diagnostics ;
33using System . IO ;
4+ using System . Text ;
45using System . Threading . Tasks ;
56using WebApiClient . Contexts ;
67
@@ -13,19 +14,34 @@ namespace WebApiClient.Parameterables
1314 public class MulitpartFile : IApiParameterable
1415 {
1516 /// <summary>
16- /// 流
17+ /// 数据流
1718 /// </summary>
1819 private readonly Stream stream ;
1920
2021 /// <summary>
21- /// 文件路径
22+ /// 本机文件路径
2223 /// </summary>
2324 private readonly string filePath ;
2425
2526 /// <summary>
26- /// 文件名
27+ /// 文件好友名称
2728 /// </summary>
28- public string FileName { get ; private set ; }
29+ private readonly string fileName ;
30+
31+ /// <summary>
32+ /// 获取文件好友名称
33+ /// </summary>
34+ public string FileName
35+ {
36+ get
37+ {
38+ if ( string . IsNullOrEmpty ( this . fileName ) )
39+ {
40+ return this . fileName ;
41+ }
42+ return HttpUtility . UrlEncode ( this . fileName , Encoding . UTF8 ) ;
43+ }
44+ }
2945
3046 /// <summary>
3147 /// 获取或设置文件的Mime
@@ -52,7 +68,7 @@ public MulitpartFile(byte[] buffer, string fileName) :
5268 public MulitpartFile ( Stream stream , string fileName )
5369 {
5470 this . stream = stream ?? throw new ArgumentNullException ( nameof ( stream ) ) ;
55- this . FileName = fileName ;
71+ this . fileName = fileName ;
5672 }
5773
5874 /// <summary>
@@ -74,7 +90,7 @@ public MulitpartFile(string localFilePath)
7490 }
7591
7692 this . filePath = localFilePath ;
77- this . FileName = Path . GetFileName ( localFilePath ) ;
93+ this . fileName = Path . GetFileName ( localFilePath ) ;
7894 }
7995
8096 /// <summary>
You can’t perform that action at this time.
0 commit comments