44using System . IO ;
55using Microsoft . AspNet . Http . Internal ;
66using Microsoft . Net . Http . Headers ;
7+ using static Microsoft . Net . Http . Headers . HeaderUtilities ;
78
89namespace Microsoft . AspNet . Http . Features . Internal
910{
1011 public class FormFile : IFormFile
1112 {
1213 private readonly Stream _baseStream ;
1314 private readonly long _baseStreamOffset ;
15+ private readonly ContentDispositionHeaderValue _contentDisposition ;
16+ private string _name ;
17+ private string _fileName ;
1418
1519 public FormFile ( Stream baseStream , long baseStreamOffset , long length , ContentDispositionHeaderValue contentDisposition )
1620 {
1721 _baseStream = baseStream ;
1822 _baseStreamOffset = baseStreamOffset ;
23+ _contentDisposition = contentDisposition ;
1924 Length = length ;
20- Name = HeaderUtilities . RemoveQuotes ( contentDisposition . Name ) ?? string . Empty ;
21- FileName = HeaderUtilities . RemoveQuotes ( contentDisposition . FileName ) ?? string . Empty ;
2225 }
2326
2427 public string ContentDisposition
@@ -37,9 +40,9 @@ public string ContentType
3740
3841 public long Length { get ; }
3942
40- public string Name { get ; }
43+ public string Name => _name ?? ( _name = RemoveQuotes ( _contentDisposition . Name ) ?? string . Empty ) ;
4144
42- public string FileName { get ; }
45+ public string FileName => _fileName ?? ( _fileName = RemoveQuotes ( _contentDisposition . FileName ) ?? string . Empty ) ;
4346
4447 public Stream OpenReadStream ( )
4548 {
0 commit comments