Skip to content

Commit 8838558

Browse files
committed
Add file search endpoint and clean up sample HTTP requests
Added a GET /search/{searchTerm} endpoint to UploadController for searching files by name in TempPath. Removed unused sample HTTP requests and weatherforecast endpoint from UDToolAPI.http.
1 parent 5a3b0d9 commit 8838558

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

UDToolAPI/Controllers/UploadController.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,14 @@ public IActionResult Download(string fileName)
4040
var fileBytes = System.IO.File.ReadAllBytes(filePath);
4141
return File(fileBytes, "application/octet-stream", fileName);
4242
}
43+
[HttpGet("search/{searchTerm}")]
44+
public IActionResult Search(string searchTerm)
45+
{
46+
if (string.IsNullOrEmpty(searchTerm))
47+
return BadRequest("Search term is required.");
48+
var files = Directory.GetFiles(TempPath, $"*{searchTerm}*");
49+
var fileNames = files.Select(Path.GetFileName).ToArray();
50+
return Ok(fileNames);
51+
}
4352
}
4453
}

UDToolAPI/UDToolAPI.http

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)