Browse Source

no message

xingzai 3 years ago
parent
commit
fab3821fd0
2 changed files with 15 additions and 1 deletions
  1. 2 1
      .gitignore
  2. 13 0
      controllers/article.go

+ 2 - 1
.gitignore

@@ -9,4 +9,5 @@
 /lastupdate.tmp
 /*.zip
 /riot-index
-/hongze_cygx
+/hongze_cygx
+/static

+ 13 - 0
controllers/article.go

@@ -5,6 +5,8 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/medivhzhan/weapp/v2"
+	"os"
+
 	//"github.com/pdfcpu/pdfcpu/pkg/api"
 	//"github.com/pdfcpu/pdfcpu/pkg/pdfcpu"
 	"hongze/hongze_cygx/models"
@@ -800,8 +802,19 @@ func (this *ArticleController) Pdfwatermark() {
 		mobile = user.Email
 	}
 	sliceLink := strings.Split(fileLink, "/")
+	uploadDir := "static/pdf/"
+	err = os.MkdirAll(uploadDir, 777)
+	if err != nil {
+		br.Msg = "存储目录创建失败"
+		br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
+		return
+	}
+
 	fmt.Println(fileLink)
 	fmt.Println(sliceLink[len(sliceLink)-1])
+	pdfName := sliceLink[len(sliceLink)-1]
+	_, err = os.Stat(uploadDir + pdfName)
+	fmt.Println(err)
 	//pdfPath := "static/"
 	//pdfUrl := fileLink
 	//fileName := utils.GetRandStringNoSpecialChar(28) + ".pdf"