From 32a24031a54db342ab5dd44910c7926fb22157ec Mon Sep 17 00:00:00 2001 From: Georg Spar Date: Fri, 23 Jun 2023 21:11:12 +0200 Subject: [PATCH] thumbs.sh --- thumbs.sh | 8 ++++++++ wdm.go | 6 ++++++ 2 files changed, 14 insertions(+) create mode 100644 thumbs.sh diff --git a/thumbs.sh b/thumbs.sh new file mode 100644 index 0000000..a97e9c7 --- /dev/null +++ b/thumbs.sh @@ -0,0 +1,8 @@ +#!/bin/bash +cd /opt/data/uploads +for i in *.png; do convert -thumbnail 80 $i thumb-$i; done; +for i in *.jpg; do convert -thumbnail 80 $i thumb-$i; done; +for i in *.jpeg; do convert -thumbnail 80 $i thumb-$i; done; +for i in *.webp; do convert -thumbnail 80 $i thumb-$i; done; +cd / + diff --git a/wdm.go b/wdm.go index 9f5c4f7..5209d6a 100644 --- a/wdm.go +++ b/wdm.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "os" + "os/exec" "strconv" "github.com/gorilla/mux" @@ -774,6 +775,11 @@ func uploadFileHandler(writer http.ResponseWriter, req *http.Request) { writer.Header().Set("Content-Type", "application/json") writer.WriteHeader(http.StatusCreated) writer.Write(b) + cmd := exec.Command("./thumbs.sh") + if err := cmd.Run(); err != nil { + log.Fatal("Error while creating thumbs: ", err) + } + log.Info("Thumbs created after photo creation") } }