图像上传接口新增格式支持
parent
b77bb98f3f
commit
1be2d54c25
|
@ -44,7 +44,7 @@ func (this *FileController) OnUpload(c *gin.Context) {
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
out.Write(bytes)
|
out.Write(bytes)
|
||||||
log.Print(len(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"){
|
if strings.Contains(types,"png"){
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
@ -55,7 +55,7 @@ func (this *FileController) OnUpload(c *gin.Context) {
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
out.Write(bytes)
|
out.Write(bytes)
|
||||||
log.Print(len(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"){
|
if strings.Contains(types,"gif"){
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
@ -66,7 +66,7 @@ func (this *FileController) OnUpload(c *gin.Context) {
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
out.Write(bytes)
|
out.Write(bytes)
|
||||||
log.Print(len(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
|
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{
|
if nil != e{
|
||||||
log.Print(e.Error())
|
log.Print(e.Error())
|
||||||
c.JSON(200,resp)
|
c.JSON(200,resp)
|
||||||
|
|
|
@ -3,7 +3,6 @@ SET GOOS=linux
|
||||||
SET GOARCH=amd64
|
SET GOARCH=amd64
|
||||||
go build ./
|
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'
|
ssh -t -i ./id_rsa ubuntu@118.24.238.198 'rm /home/ubuntu/api/bin/userapi'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue