From e845dbe5a5a43b96829e768f5bdd57d07b2806f5 Mon Sep 17 00:00:00 2001 From: Azareal Date: Thu, 31 Oct 2019 05:25:45 +1000 Subject: [PATCH] Add a hidden flag to disable on the spot image encoding. Update README. --- README.md | 2 +- routes/topic.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 334d6c78..993bb305 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Other modern features like alerts, likes, advanced dashboard with live stats (CP # Requirements -Go 1.11 or newer - You will need to install this. Pick the .msi, if you want everything sorted out for you rather than having to go around updating the environment settings. https://golang.org/doc/install +Go 1.12 or newer - You will need to install this. Pick the .msi, if you want everything sorted out for you rather than having to go around updating the environment settings. https://golang.org/doc/install For Ubuntu, you can consult: https://tecadmin.net/install-go-on-ubuntu/ You will also want to run `ln -s /usr/local/go/bin/go` (replace /usr/local with where ever you put Go), so that go becomes visible to other users. diff --git a/routes/topic.go b/routes/topic.go index 1cd07b60..aad18e67 100644 --- a/routes/topic.go +++ b/routes/topic.go @@ -450,6 +450,7 @@ func uploadFilesWithHash(w http.ResponseWriter, r *http.Request, user c.User, di if len(files) > 5 { return nil, c.LocalError("You can't attach more than five files", w, r, user) } + disableEncode := r.PostFormValue("ko") == "1" for _, file := range files { if file.Filename == "" { @@ -495,7 +496,7 @@ func uploadFilesWithHash(w http.ResponseWriter, r *http.Request, user c.User, di } defer inFile.Close() - if ext != "jpg" && ext != "jpeg" && ext != "png" && ext != "gif" && ext != "tiff" && ext != "tif" { + if disableEncode || (ext != "jpg" && ext != "jpeg" && ext != "png" && ext != "gif" && ext != "tiff" && ext != "tif") { outFile, err := os.Create(dir + filename) if err != nil { return nil, c.LocalError("Upload failed [File Creation Failed]", w, r, user)