aboutsummaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
Diffstat (limited to 'Backend')
-rw-r--r--Backend/Api/Api/Controllers/PostController.cs17
1 files changed, 16 insertions, 1 deletions
diff --git a/Backend/Api/Api/Controllers/PostController.cs b/Backend/Api/Api/Controllers/PostController.cs
index 31dbeef..62f77f1 100644
--- a/Backend/Api/Api/Controllers/PostController.cs
+++ b/Backend/Api/Api/Controllers/PostController.cs
@@ -13,9 +13,11 @@ namespace Api.Controllers
public class PostController : ControllerBase
{
private readonly IPostService _postService;
- public PostController(IPostService postService)
+ private readonly IFileService _fileService;
+ public PostController(IPostService postService, IFileService fileService)
{
_postService = postService;
+ _fileService = fileService;
}
[HttpPost("add")]
@@ -52,5 +54,18 @@ namespace Api.Controllers
return BadRequest();
}
+ [HttpGet("image/{id}")]
+ [Authorize(Roles = "User")]
+ public async Task<ActionResult> getImage(string id)
+ {
+ Models.File f =await _fileService.getById(id);
+ if (f == null || !System.IO.File.Exists(f.path))
+ return BadRequest("Slika ne postoji");
+ return File(System.IO.File.ReadAllBytes(f.path), "image/*", Path.GetFileName(f.path));
+
+
+ }
+
+
}
}