From 0c3c09824e037fc4513ec85b56c04039f4a77d2e Mon Sep 17 00:00:00 2001 From: Joao Rua Date: Wed, 17 Apr 2024 09:07:31 +0100 Subject: [PATCH] only creates a folder with uploaded data when a file is uploaded --- .../FileRevisionHandlerViewModel.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileRevisionHandler/FileRevisionHandlerViewModel.cs b/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileRevisionHandler/FileRevisionHandlerViewModel.cs index 04eafd7b..0019b3a7 100644 --- a/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileRevisionHandler/FileRevisionHandlerViewModel.cs +++ b/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileRevisionHandler/FileRevisionHandlerViewModel.cs @@ -127,11 +127,6 @@ public void InitializeViewModel(File file, FileStore fileStore) this.FileTypes = this.SessionService.GetSiteDirectory().AvailableReferenceDataLibraries().SelectMany(x => x.FileType); this.ErrorMessage = string.Empty; this.UploadsDirectory = Path.Combine("wwwroot", "uploads", Guid.NewGuid().ToString()); - - if (!Directory.Exists(this.UploadsDirectory)) - { - Directory.CreateDirectory(this.UploadsDirectory); - } } /// @@ -173,6 +168,11 @@ public async Task UploadFile(IBrowserFile file) return; } + if (!Directory.Exists(this.UploadsDirectory)) + { + Directory.CreateDirectory(this.UploadsDirectory); + } + var uploadedFilePath = Path.Combine(this.UploadsDirectory, Guid.NewGuid().ToString()); await using (var fileStream = new FileStream(uploadedFilePath, FileMode.Create))