fixes the route to file posting

main
Paul Schneider 7 years ago
parent 878c7e6476
commit 61b00aa515
1 changed files with 7 additions and 4 deletions

@ -42,7 +42,7 @@ namespace Yavsc.ApiControllers
return GetDir(null); return GetDir(null);
} }
[HttpGet("{subdir}")] [HttpGet("{*subdir}")]
public IActionResult GetDir(string subdir="") public IActionResult GetDir(string subdir="")
{ {
if (subdir !=null) if (subdir !=null)
@ -52,7 +52,7 @@ namespace Yavsc.ApiControllers
return Ok(files); return Ok(files);
} }
[HttpPost("{subdir}")] [HttpPost("{*subdir}")]
public IActionResult Post(string subdir="") public IActionResult Post(string subdir="")
{ {
string destDir = null; string destDir = null;
@ -63,9 +63,12 @@ namespace Yavsc.ApiControllers
} catch (InvalidPathException ex) { } catch (InvalidPathException ex) {
pathex = 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}')."); logger.LogInformation($"Recieving files, saved in '{destDir}' (specified ad '{subdir}').");
if (pathex!=null)
return new BadRequestObjectResult(pathex);
var uid = User.GetUserId(); var uid = User.GetUserId();
var user = dbContext.Users.Single( var user = dbContext.Users.Single(
u => u.Id == uid u => u.Id == uid

Loading…