diff options
author | Ivan Ljubisavljevic <ivan996sk@gmail.com> | 2022-04-26 20:47:04 +0200 |
---|---|---|
committer | Ivan Ljubisavljevic <ivan996sk@gmail.com> | 2022-04-26 20:47:04 +0200 |
commit | e859227a3722f28f858d6bb4cedfdd7b868680ff (patch) | |
tree | 7f54dd92b3226d7e072514318caa4b94ae99d370 /backend | |
parent | b23f781aedd6c7b8ba57d457ea8690401352e44b (diff) |
Dodat api za prikaz odredjenih redova u csv-u
Diffstat (limited to 'backend')
-rw-r--r-- | backend/api/api/Controllers/FileController.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/backend/api/api/Controllers/FileController.cs b/backend/api/api/Controllers/FileController.cs index 68d2ebed..0e9f9b97 100644 --- a/backend/api/api/Controllers/FileController.cs +++ b/backend/api/api/Controllers/FileController.cs @@ -115,6 +115,26 @@ namespace api.Controllers return String.Join("\n", System.IO.File.ReadLines(filePath).Take(10)); } + [HttpGet("csvread/{hasHeader}/{fileId}/{skipRows}/{takeRows}")] + [Authorize(Roles = "User,Guest")] + public ActionResult<string> CsvRead(bool hasHeader, string fileId, int skipRows, int takeRows) + { + + string uploaderId = getUserId(); + + if (uploaderId == null) + return BadRequest(); + + //String csvContent = System.IO.File.ReadAllText(fileModel.path); + string filePath = _fileservice.GetFilePath(fileId, uploaderId); + + + + if (hasHeader) + return String.Join("\n", System.IO.File.ReadLines(filePath).Skip(skipRows+1).Take(takeRows)); + else + return String.Join("\n", System.IO.File.ReadLines(filePath).Skip(skipRows).Take(takeRows)); + } [HttpPost("Csv")] |