This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user