From 61b00aa515ca8b4e68bb21f1c65a7f9e78f95c9f Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 30 Jul 2018 09:37:35 +0200 Subject: [PATCH] fixes the route to file posting --- Yavsc/ApiControllers/FileSystemApiController.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Yavsc/ApiControllers/FileSystemApiController.cs b/Yavsc/ApiControllers/FileSystemApiController.cs index 3ed0f0db..4094ddf6 100644 --- a/Yavsc/ApiControllers/FileSystemApiController.cs +++ b/Yavsc/ApiControllers/FileSystemApiController.cs @@ -42,7 +42,7 @@ namespace Yavsc.ApiControllers return GetDir(null); } - [HttpGet("{subdir}")] + [HttpGet("{*subdir}")] public IActionResult GetDir(string subdir="") { if (subdir !=null) @@ -52,7 +52,7 @@ namespace Yavsc.ApiControllers return Ok(files); } - [HttpPost("{subdir}")] + [HttpPost("{*subdir}")] public IActionResult Post(string subdir="") { string destDir = null; @@ -63,9 +63,12 @@ namespace Yavsc.ApiControllers } catch (InvalidPathException ex) { pathex = ex; } + if (pathex!=null) { + logger.LogError($"invalid sub path: '{subdir}'."); + return HttpBadRequest(pathex); + } logger.LogInformation($"Recieving files, saved in '{destDir}' (specified ad '{subdir}')."); - if (pathex!=null) - return new BadRequestObjectResult(pathex); + var uid = User.GetUserId(); var user = dbContext.Users.Single( u => u.Id == uid