From f3d97b800c38183eb07b839b922e460780866a98 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 28 Dec 2025 08:23:18 +0000 Subject: [PATCH] fix: Create parent directories for uploaded files with subdirectory paths When file.FileName contains subdirectories (e.g., "client\resources\animations\Campfire.png"), the upload would fail with DirectoryNotFoundException because intermediate directories weren't created. Added check to create parent directory structure before writing each file, fixing 400 errors on POST /api/v1/editor/updates/client endpoint. Fixes issue where uploading files with nested paths would fail even though the base destination folder was created. --- .../Web/Controllers/Api/EditorUpdatesController.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Intersect.Server/Web/Controllers/Api/EditorUpdatesController.cs b/Intersect.Server/Web/Controllers/Api/EditorUpdatesController.cs index 8aec6079e8..d98fd6b256 100644 --- a/Intersect.Server/Web/Controllers/Api/EditorUpdatesController.cs +++ b/Intersect.Server/Web/Controllers/Api/EditorUpdatesController.cs @@ -193,6 +193,16 @@ private async Task UploadFilesInternal( try { + // Ensure the parent directory exists (file.FileName may contain subdirectories) + if (fileInfo.Directory != null && !fileInfo.Directory.Exists) + { + fileInfo.Directory.Create(); + _logger.LogDebug( + "Created directory for file upload: {DirectoryPath}", + Path.GetRelativePath(assetRootPath, fileInfo.Directory.FullName) + ); + } + // Write the file (overwrites if exists - this is intentional for updates) using var networkStream = file.OpenReadStream(); using var targetStream = fileInfo.Open(