2019-12-30 19:08:38 +08:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
2020-01-15 10:14:15 +08:00
|
|
|
"github.com/HFO4/cloudreve/pkg/serializer"
|
2019-12-30 19:08:38 +08:00
|
|
|
"github.com/HFO4/cloudreve/service/callback"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RemoteCallback 远程上传回调
|
|
|
|
func RemoteCallback(c *gin.Context) {
|
|
|
|
var callbackBody callback.RemoteUploadCallbackService
|
|
|
|
if err := c.ShouldBindJSON(&callbackBody); err == nil {
|
2020-01-15 10:14:15 +08:00
|
|
|
res := callback.ProcessCallback(callbackBody, c)
|
2019-12-30 19:08:38 +08:00
|
|
|
c.JSON(200, res)
|
|
|
|
} else {
|
|
|
|
c.JSON(200, ErrorResponse(err))
|
|
|
|
}
|
|
|
|
}
|
2020-01-15 10:14:15 +08:00
|
|
|
|
|
|
|
// QiniuCallback 七牛上传回调
|
|
|
|
func QiniuCallback(c *gin.Context) {
|
2020-01-16 13:36:13 +08:00
|
|
|
var callbackBody callback.UploadCallbackService
|
2020-01-15 10:14:15 +08:00
|
|
|
if err := c.ShouldBindJSON(&callbackBody); err == nil {
|
|
|
|
res := callback.ProcessCallback(callbackBody, c)
|
|
|
|
if res.Code != 0 {
|
|
|
|
c.JSON(401, serializer.QiniuCallbackFailed{Error: res.Msg})
|
|
|
|
} else {
|
|
|
|
c.JSON(200, res)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
c.JSON(401, ErrorResponse(err))
|
|
|
|
}
|
|
|
|
}
|
2020-01-16 13:36:13 +08:00
|
|
|
|
|
|
|
// OSSCallback 阿里云OSS上传回调
|
|
|
|
func OSSCallback(c *gin.Context) {
|
|
|
|
var callbackBody callback.UploadCallbackService
|
|
|
|
if err := c.ShouldBindJSON(&callbackBody); err == nil {
|
|
|
|
res := callback.ProcessCallback(callbackBody, c)
|
|
|
|
c.JSON(200, res)
|
|
|
|
} else {
|
|
|
|
c.JSON(200, ErrorResponse(err))
|
|
|
|
}
|
|
|
|
}
|