id length selection in upload

This commit is contained in:
2026-11-14 14:39:21 -05:00
parent 507ff7359c
commit c4222a16b2
3 changed files with 21 additions and 9 deletions
+8 -5
View File
@@ -81,11 +81,6 @@ func uploadHandler(db *gorm.DB, cfg Config, pages *template.Template) http.Handl
}
}
idLength := 16
if r.URL.Query().Get("idlength") == "short" {
idLength = 10
}
returnType := strings.TrimSpace(r.URL.Query().Get("return"))
if returnType == "" {
returnType = "json"
@@ -175,6 +170,14 @@ func uploadHandler(db *gorm.DB, cfg Config, pages *template.Template) http.Handl
return
}
idLength := 16
if r.URL.Query().Get("idlength") == "short" {
idLength = 10
}
if r.PostForm.Get("idlength") == "short" {
idLength = 10
}
id := generateId(idLength)
path := getStoragePath(cfg.UploadDir, id)
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {