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") } }