Add a hidden flag to disable on the spot image encoding.

Update README.
This commit is contained in:
Azareal 2019-10-31 05:25:45 +10:00
parent e9cf06a5f2
commit e845dbe5a5
2 changed files with 3 additions and 2 deletions

View File

@ -37,7 +37,7 @@ Other modern features like alerts, likes, advanced dashboard with live stats (CP
# Requirements # 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/ 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. 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.

View File

@ -450,6 +450,7 @@ func uploadFilesWithHash(w http.ResponseWriter, r *http.Request, user c.User, di
if len(files) > 5 { if len(files) > 5 {
return nil, c.LocalError("You can't attach more than five files", w, r, user) return nil, c.LocalError("You can't attach more than five files", w, r, user)
} }
disableEncode := r.PostFormValue("ko") == "1"
for _, file := range files { for _, file := range files {
if file.Filename == "" { if file.Filename == "" {
@ -495,7 +496,7 @@ func uploadFilesWithHash(w http.ResponseWriter, r *http.Request, user c.User, di
} }
defer inFile.Close() 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) outFile, err := os.Create(dir + filename)
if err != nil { if err != nil {
return nil, c.LocalError("Upload failed [File Creation Failed]", w, r, user) return nil, c.LocalError("Upload failed [File Creation Failed]", w, r, user)