4
4
using System . IO ;
5
5
using Microsoft . AspNet . Http . Internal ;
6
6
using Microsoft . Net . Http . Headers ;
7
+ using static Microsoft . Net . Http . Headers . HeaderUtilities ;
7
8
8
9
namespace Microsoft . AspNet . Http . Features . Internal
9
10
{
10
11
public class FormFile : IFormFile
11
12
{
12
13
private readonly Stream _baseStream ;
13
14
private readonly long _baseStreamOffset ;
15
+ private readonly ContentDispositionHeaderValue _contentDisposition ;
16
+ private string _name ;
17
+ private string _fileName ;
14
18
15
19
public FormFile ( Stream baseStream , long baseStreamOffset , long length , ContentDispositionHeaderValue contentDisposition )
16
20
{
17
21
_baseStream = baseStream ;
18
22
_baseStreamOffset = baseStreamOffset ;
23
+ _contentDisposition = contentDisposition ;
19
24
Length = length ;
20
- Name = HeaderUtilities . RemoveQuotes ( contentDisposition . Name ) ?? string . Empty ;
21
- FileName = HeaderUtilities . RemoveQuotes ( contentDisposition . FileName ) ?? string . Empty ;
22
25
}
23
26
24
27
public string ContentDisposition
@@ -37,9 +40,9 @@ public string ContentType
37
40
38
41
public long Length { get ; }
39
42
40
- public string Name { get ; }
43
+ public string Name => _name ?? ( _name = RemoveQuotes ( _contentDisposition . Name ) ?? string . Empty ) ;
41
44
42
- public string FileName { get ; }
45
+ public string FileName => _fileName ?? ( _fileName = RemoveQuotes ( _contentDisposition . FileName ) ?? string . Empty ) ;
43
46
44
47
public Stream OpenReadStream ( )
45
48
{
0 commit comments