Skip to content

Commit

Permalink
only creates a folder with uploaded data when a file is uploaded
Browse files Browse the repository at this point in the history
  • Loading branch information
joao4all committed Apr 17, 2024
1 parent 0014073 commit 0c3c098
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/// <summary>
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 0c3c098

Please sign in to comment.