diff --git a/.gitignore b/.gitignore index bff1ec1..ff9cdef 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ pem/client-cert.pem pem/ca.pem id_rsa background +image/ diff --git a/controller/blog.go b/controller/blog.go index c50b4d0..8da57e8 100644 --- a/controller/blog.go +++ b/controller/blog.go @@ -51,7 +51,11 @@ func GetArticles(c *gin.Context) { logs.Error(e.Error()) return } + for k,_ := range article{ + article[k].Content += "..." + } rsp.Data = article + rsp.Status = 0 rsp.Msg = "OK" } diff --git a/controller/file.go b/controller/file.go index bc5c040..822850b 100644 --- a/controller/file.go +++ b/controller/file.go @@ -46,6 +46,28 @@ func (this *FileController) OnUpload(c *gin.Context) { log.Print(len(bytes)) c.JSON(200, map[string] interface{}{"url":uid.String()}) } + if strings.Contains(types,"png"){ + defer file.Close() + out, err := os.Create("image/" + uid.String() + ".png") + if err != nil { + log.Fatal(err) + } + defer out.Close() + out.Write(bytes) + log.Print(len(bytes)) + c.JSON(200, map[string] interface{}{"url":uid.String()}) + } + if strings.Contains(types,"gif"){ + defer file.Close() + out, err := os.Create("image/" + uid.String() + ".gif") + if err != nil { + log.Fatal(err) + } + defer out.Close() + out.Write(bytes) + log.Print(len(bytes)) + c.JSON(200, map[string] interface{}{"url":uid.String()}) + } } func (this *FileController) OnDownLoad(c *gin.Context) { diff --git a/deploy.bat b/deploy.bat index a74f768..fa9aa90 100644 --- a/deploy.bat +++ b/deploy.bat @@ -3,6 +3,7 @@ SET GOOS=linux SET GOARCH=amd64 go build ./ +ssh -t -i ./id_rsa ubuntu@118.24.238.198 'pkill userapi' ssh -t -i ./id_rsa ubuntu@118.24.238.198 'rm /home/ubuntu/api/bin/userapi'