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