@@ -74,28 +74,20 @@ public Stream OpenReadStream()
74
74
/// <summary>
75
75
/// Saves the contents of the uploaded file.
76
76
/// </summary>
77
- /// <param name="path ">The path of the file to create .</param>
78
- public void SaveAs ( string path )
77
+ /// <param name="target ">The stream to save the file to.</param>
78
+ public void Save ( Stream target )
79
79
{
80
- using ( var fileStream = File . Create ( path , DefaultBufferSize ) )
81
- {
82
- var inputStream = OpenReadStream ( ) ;
83
- inputStream . CopyTo ( fileStream , DefaultBufferSize ) ;
84
- }
80
+ OpenReadStream ( ) . CopyTo ( target , DefaultBufferSize ) ;
85
81
}
86
82
87
83
/// <summary>
88
84
/// Asynchronously saves the contents of the uploaded file.
89
85
/// </summary>
90
- /// <param name="path ">The path of the file to create .</param>
86
+ /// <param name="target ">The stream to save the file to.</param>
91
87
/// <param name="cancellationToken"></param>
92
- public async Task SaveAsAsync ( string path , CancellationToken cancellationToken = default ( CancellationToken ) )
88
+ public async Task SaveAsync ( Stream target , CancellationToken cancellationToken = default ( CancellationToken ) )
93
89
{
94
- using ( var fileStream = File . Create ( path , DefaultBufferSize , FileOptions . Asynchronous ) )
95
- {
96
- var inputStream = OpenReadStream ( ) ;
97
- await inputStream . CopyToAsync ( fileStream , DefaultBufferSize , cancellationToken ) ;
98
- }
90
+ await OpenReadStream ( ) . CopyToAsync ( target , DefaultBufferSize , cancellationToken ) ;
99
91
}
100
92
}
101
93
}
0 commit comments