add secret force upload function
This commit is contained in:
parent
237b9036ce
commit
c7fdd04e88
1 changed files with 8 additions and 5 deletions
13
go/main.go
13
go/main.go
|
@ -105,11 +105,14 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mimeType := http.DetectContentType(buffer)
|
forceUpload := r.FormValue("force_upload")
|
||||||
if !strings.HasPrefix(mimeType, "image/") && !strings.HasPrefix(mimeType, "text/xml") && !strings.HasPrefix(mimeType, "image/svg+xml") {
|
if forceUpload != "true" {
|
||||||
http.Error(w, "Nur Bild-Uploads sind erlaubt", http.StatusBadRequest)
|
mimeType := http.DetectContentType(buffer)
|
||||||
log.Printf("Versuch, eine Nicht-Bild-Datei hochzuladen: %v", mimeType)
|
if !strings.HasPrefix(mimeType, "image/") && !strings.HasPrefix(mimeType, "text/xml") && !strings.HasPrefix(mimeType, "image/svg+xml") {
|
||||||
return
|
http.Error(w, "Nur Bild-Uploads sind erlaubt", http.StatusBadRequest)
|
||||||
|
log.Printf("Versuch, eine Nicht-Bild-Datei hochzuladen: %v", mimeType)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = file.Seek(0, io.SeekStart)
|
_, err = file.Seek(0, io.SeekStart)
|
||||||
|
|
Loading…
Reference in a new issue