id length selection in upload
This commit is contained in:
+8
-5
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user