Feat: qiniu upload & callback

This commit is contained in:
HFO4
2020-01-15 10:14:15 +08:00
parent 5be7ec98c1
commit e8d21b1e9b
15 changed files with 356 additions and 71 deletions

View File

@@ -5,6 +5,7 @@ import (
model "github.com/HFO4/cloudreve/models"
"github.com/HFO4/cloudreve/pkg/cache"
"github.com/HFO4/cloudreve/pkg/filesystem/fsctx"
"github.com/HFO4/cloudreve/pkg/filesystem/local"
"github.com/HFO4/cloudreve/pkg/serializer"
"github.com/HFO4/cloudreve/pkg/util"
"github.com/gin-gonic/gin"
@@ -146,6 +147,11 @@ func (fs *FileSystem) GetUploadToken(ctx context.Context, path string, size uint
var err error
// 是否需要预先生成存储路径
if fs.User.Policy.IsPathGenerateNeeded() {
ctx = context.WithValue(ctx, fsctx.SavePathCtx, fs.GenerateSavePath(ctx, local.FileStream{}))
}
// 获取上传凭证
callbackKey := util.RandStringRunes(32)
credential, err := fs.Handler.Token(ctx, int64(credentialTTL), callbackKey)