From b77bb98f3fa11a40e737667359de7466695285a2 Mon Sep 17 00:00:00 2001 From: a7458969 <290198252@qq.com> Date: Sat, 28 Dec 2019 15:37:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=AF=B9png=E5=92=8Cgif=E6=A0=BC=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + controller/blog.go | 4 ++++ controller/file.go | 22 ++++++++++++++++++++++ deploy.bat | 1 + 4 files changed, 28 insertions(+) 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'