Make all files and directories in the config absolute

This commit is contained in:
2025-01-19 08:59:36 +01:00
parent 5552e6d2eb
commit 5d251c3659
5 changed files with 43 additions and 48 deletions

View File

@@ -44,17 +44,11 @@ func UploadPDF(c *b.Config, s map[string]*Session) http.HandlerFunc {
return
}
oldFilename := header.Filename
oldFilename = strings.Join(strings.Split(oldFilename, ".")[:len(oldFilename)-1], ".")
oldFilename := strings.Join(strings.Split(header.Filename, ".")[:len(header.Filename)-1], ".")
filename := fmt.Sprint(oldFilename, ".", uuid.New(), ".pdf")
absFilepath, err := filepath.Abs(c.PDFDir + "/" + filename)
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
filepath := filepath.Join(c.PDFDir, filename)
if err = b.WriteFile(absFilepath, file); err != nil {
if err = b.WriteFile(filepath, file); err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return