Skip to content

Commit 9816662

Browse files
Update Web/Resgrid.Web/Areas/User/Controllers/TrainingsController.cs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 0f57208 commit 9816662

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Web/Resgrid.Web/Areas/User/Controllers/TrainingsController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,9 @@ public async Task<IActionResult> Edit(int trainingId, EditTrainingModel model, I
301301
attachment.FileName = file.FileName;
302302
attachment.TrainingId = trainingId;
303303

304-
var uploadedFile = new byte[file.OpenReadStream().Length];
305-
file.OpenReadStream().Read(uploadedFile, 0, uploadedFile.Length);
304+
using var stream = file.OpenReadStream();
305+
var uploadedFile = new byte[stream.Length];
306+
stream.Read(uploadedFile, 0, uploadedFile.Length);
306307

307308
attachment.Data = uploadedFile;
308309
existingTraining.Attachments.Add(attachment);

0 commit comments

Comments
 (0)