This repository was archived by the owner on Nov 20, 2018. It is now read-only.
File tree 2 files changed +24
-11
lines changed
src/Microsoft.AspNet.Http
2 files changed +24
-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
+ // Copyright (c) .NET Foundation. All rights reserved.
2
+ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
+
4
+ using Microsoft . Net . Http . Headers ;
5
+
6
+ namespace Microsoft . AspNet . Http
7
+ {
8
+ public static class FormFileExtensions
9
+ {
10
+ public static string GetName ( this IFormFile file )
11
+ {
12
+ // Content-Disposition: form-data; name="myfile1"; filename="Misc 002.jpg"
13
+ ContentDispositionHeaderValue cd ;
14
+ if ( ContentDispositionHeaderValue . TryParse ( file . ContentDisposition , out cd ) )
15
+ {
16
+ return HeaderUtilities . RemoveQuotes ( cd . Name ) ;
17
+ }
18
+
19
+ return string . Empty ;
20
+ }
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments