Feat: update file content

This commit is contained in:
HFO4
2019-12-15 14:01:37 +08:00
parent 2c75c73886
commit 8bf2966d46
6 changed files with 175 additions and 10 deletions

View File

@@ -143,7 +143,7 @@ func Preview(c *gin.Context) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var service explorer.FileDownloadCreateService
var service explorer.SingleFileService
if err := c.ShouldBindUri(&service); err == nil {
res := service.PreviewContent(ctx, c)
// 是否需要重定向
@@ -164,7 +164,7 @@ func CreateDownloadSession(c *gin.Context) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var service explorer.FileDownloadCreateService
var service explorer.SingleFileService
if err := c.ShouldBindUri(&service); err == nil {
res := service.CreateDownloadSession(ctx, c)
c.JSON(200, res)
@@ -190,6 +190,21 @@ func Download(c *gin.Context) {
}
}
// PutContent 更新文件内容
func PutContent(c *gin.Context) {
// 创建上下文
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var service explorer.SingleFileService
if err := c.ShouldBindUri(&service); err == nil {
res := service.PutContent(ctx, c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
}
}
// FileUploadStream 本地策略流式上传
func FileUploadStream(c *gin.Context) {
// 创建上下文
@@ -251,6 +266,5 @@ func FileUploadStream(c *gin.Context) {
c.JSON(200, serializer.Response{
Code: 0,
Msg: "Pong",
})
}