This repository was archived by the owner on Nov 20, 2018. It is now read-only.
File tree 2 files changed +21
-11
lines changed
src/Microsoft.AspNet.Http
2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change 2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
4
using System . Collections . Generic ;
5
- using Microsoft . Net . Http . Headers ;
6
5
7
6
namespace Microsoft . AspNet . Http . Internal
8
7
{
@@ -15,20 +14,12 @@ public IFormFile this[string name]
15
14
16
15
public IFormFile GetFile ( string name )
17
16
{
18
- return Find ( file => string . Equals ( name , GetName ( file . ContentDisposition ) ) ) ;
17
+ return Find ( file => string . Equals ( name , file . GetName ( ) ) ) ;
19
18
}
20
19
21
20
public IReadOnlyList < IFormFile > GetFiles ( string name )
22
21
{
23
- return FindAll ( file => string . Equals ( name , GetName ( file . ContentDisposition ) ) ) ;
24
- }
25
-
26
- private static string GetName ( string contentDisposition )
27
- {
28
- // Content-Disposition: form-data; name="myfile1"; filename="Misc 002.jpg"
29
- ContentDispositionHeaderValue cd ;
30
- ContentDispositionHeaderValue . TryParse ( contentDisposition , out cd ) ;
31
- return HeaderUtilities . RemoveQuotes ( cd ? . Name ) ;
22
+ return FindAll ( file => string . Equals ( name , file . GetName ( ) ) ) ;
32
23
}
33
24
}
34
25
}
Original file line number Diff line number Diff line change
1
+ using Microsoft . Net . Http . Headers ;
2
+
3
+ namespace Microsoft . AspNet . Http
4
+ {
5
+ public static class FormFileExtensions
6
+ {
7
+ public static string GetName ( this IFormFile file )
8
+ {
9
+ // Content-Disposition: form-data; name="myfile1"; filename="Misc 002.jpg"
10
+ ContentDispositionHeaderValue cd ;
11
+ if ( ContentDispositionHeaderValue . TryParse ( file . ContentDisposition , out cd ) )
12
+ {
13
+ return HeaderUtilities . RemoveQuotes ( cd . Name ) ;
14
+ }
15
+
16
+ return string . Empty ;
17
+ }
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments