图像上传接口新增格式支持

master
a7458969 2019-12-29 17:42:27 +08:00
parent b77bb98f3f
commit 1be2d54c25
2 changed files with 4 additions and 5 deletions

View File

@ -44,7 +44,7 @@ func (this *FileController) OnUpload(c *gin.Context) {
defer out.Close()
out.Write(bytes)
log.Print(len(bytes))
c.JSON(200, map[string] interface{}{"url":uid.String()})
c.JSON(200, map[string] interface{}{"url":uid.String() + ".jpg" })
}
if strings.Contains(types,"png"){
defer file.Close()
@ -55,7 +55,7 @@ func (this *FileController) OnUpload(c *gin.Context) {
defer out.Close()
out.Write(bytes)
log.Print(len(bytes))
c.JSON(200, map[string] interface{}{"url":uid.String()})
c.JSON(200, map[string] interface{}{"url":uid.String() + ".png" })
}
if strings.Contains(types,"gif"){
defer file.Close()
@ -66,7 +66,7 @@ func (this *FileController) OnUpload(c *gin.Context) {
defer out.Close()
out.Write(bytes)
log.Print(len(bytes))
c.JSON(200, map[string] interface{}{"url":uid.String()})
c.JSON(200, map[string] interface{}{"url":uid.String() + ".gif" } )
}
}
@ -79,7 +79,7 @@ func (this *FileController) OnDownLoad(c *gin.Context) {
return
}
file,e := os.Open("/home/ubuntu/api/bin/image/" +fileName + ".jpg")
file,e := os.Open("/home/ubuntu/api/bin/image/" +fileName)
if nil != e{
log.Print(e.Error())
c.JSON(200,resp)

View File

@ -3,7 +3,6 @@ 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'