aboutsummaryrefslogtreecommitdiff
path: root/Backend/Api
diff options
context:
space:
mode:
authorOgnjen Cirkovic <ciraboxkg@gmail.com>2022-11-27 15:43:25 +0100
committerOgnjen Cirkovic <ciraboxkg@gmail.com>2022-11-27 15:43:25 +0100
commite06bc945b7f0cffa0cf2ee9e26440ba5f6e7b461 (patch)
tree914daad9f7fe226d4019924361d27edf443e00ec /Backend/Api
parentae56615b88ec9e353615c6e5741b2e0fc8fe8dc2 (diff)
Ukoliko postoji kompresovana slika on je samo vraca , ukoliko ne upisuje je na fajl sistem i vraca bytearray. Dodati pozivi za preuzimanje kompresovanih slika na clientu.
Diffstat (limited to 'Backend/Api')
-rw-r--r--Backend/Api/Api/Services/FileService.cs3
1 files changed, 3 insertions, 0 deletions
diff --git a/Backend/Api/Api/Services/FileService.cs b/Backend/Api/Api/Services/FileService.cs
index b951efc..440b24f 100644
--- a/Backend/Api/Api/Services/FileService.cs
+++ b/Backend/Api/Api/Services/FileService.cs
@@ -31,11 +31,14 @@ namespace Api.Services
Models.File f = await getById(id);
if (f == null || !System.IO.File.Exists(f.path))
return res;
+ if (System.IO.File.Exists(f.path + "-compress"))
+ return System.IO.File.ReadAllBytes(f.path + "-compress");
using (MagickImage image = new MagickImage(f.path))
{
image.Format = image.Format;
image.Quality = 30;
res= image.ToByteArray();
+ image.Write(f.path + "-compress");
}