replace spaces in filenames
All checks were successful
Go / build (push) Successful in 14m52s

This commit is contained in:
2026-01-19 11:54:36 +01:00
parent faf07704d2
commit cfdfae84bb

View File

@@ -6,6 +6,7 @@ import (
"os/exec"
"path/filepath"
"strconv"
"strings"
"github.com/gin-gonic/gin"
@@ -83,6 +84,7 @@ func (rc *shopItemController) NewShopItemFromForm(ctx *gin.Context) (models.Shop
if err == nil {
dstImage = filepath.Join("static/uploads", image.Filename)
dstImage = strings.ReplaceAll(dstImage, " ", "_")
if err := ctx.SaveUploadedFile(image, dstImage); err != nil {
return models.ShopItem{}, fmt.Errorf("Could not save image")
}
@@ -93,6 +95,7 @@ func (rc *shopItemController) NewShopItemFromForm(ctx *gin.Context) (models.Shop
if err == nil {
dstPdf = filepath.Join("static/uploads", pdf.Filename)
dstPdf = strings.ReplaceAll(dstPdf, " ", "_")
fmt.Println("Saving pdf at ", dstPdf)
if err := ctx.SaveUploadedFile(pdf, dstPdf); err != nil {
return models.ShopItem{}, fmt.Errorf("Could not save PDF")
@@ -366,6 +369,8 @@ func (rc *shopItemController) AddItemsHandler(c *gin.Context) {
var shopItems []models.ShopItem
for _, file := range files {
dstPdf := filepath.Join("static/uploads", file.Filename)
dstPdf = strings.ReplaceAll(dstPdf, " ", "_")
fmt.Println("Saving pdf at ", dstPdf)
if err := c.SaveUploadedFile(file, dstPdf); err != nil {
errorHandler(err)