aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Ljubisavljevic <ivan996sk@gmail.com>2022-04-26 20:47:04 +0200
committerIvan Ljubisavljevic <ivan996sk@gmail.com>2022-04-26 20:47:04 +0200
commite859227a3722f28f858d6bb4cedfdd7b868680ff (patch)
tree7f54dd92b3226d7e072514318caa4b94ae99d370
parentb23f781aedd6c7b8ba57d457ea8690401352e44b (diff)
Dodat api za prikaz odredjenih redova u csv-u
-rw-r--r--backend/api/api/Controllers/FileController.cs20
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")]