增加图片上传对png和gif格式的支持
parent
dab24f3f84
commit
b77bb98f3f
|
@ -9,3 +9,4 @@ pem/client-cert.pem
|
|||
pem/ca.pem
|
||||
id_rsa
|
||||
background
|
||||
image/
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
Loading…
Reference in New Issue