parent
ca9f44c06c
commit
d29b7ef6f8
@ -0,0 +1,17 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"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 {
|
||||
res := callbackBody.Process(c)
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package callback
|
||||
|
||||
import (
|
||||
"github.com/HFO4/cloudreve/pkg/filesystem"
|
||||
"github.com/HFO4/cloudreve/pkg/serializer"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// RemoteUploadCallbackService 远程存储上传回调请求服务
|
||||
type RemoteUploadCallbackService struct {
|
||||
Data serializer.RemoteUploadCallback `json:"data" binding:"required"`
|
||||
}
|
||||
|
||||
// Process 处理远程策略上传结果回调
|
||||
func (service *RemoteUploadCallbackService) Process(c *gin.Context) serializer.Response {
|
||||
// 创建文件系统
|
||||
fs, err := filesystem.NewFileSystemFromContext(c)
|
||||
if err != nil {
|
||||
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
|
||||
}
|
||||
defer fs.Recycle()
|
||||
|
||||
return serializer.Response{
|
||||
Code: 0,
|
||||
}
|
||||
}
|
Loading…
Reference in new issue