Feat: file uploading in slave mode

This commit is contained in:
HFO4
2019-12-28 13:14:00 +08:00
parent 6470340104
commit 132c7a8fcb
8 changed files with 85 additions and 9 deletions

View File

@@ -54,7 +54,6 @@ func HookIsFileExist(ctx context.Context, fs *FileSystem) error {
}
// HookSlaveUploadValidate Slave模式下对文件上传的一系列验证
// TODO 测试
func HookSlaveUploadValidate(ctx context.Context, fs *FileSystem) error {
file := ctx.Value(fsctx.FileHeaderCtx).(FileHeader)
policy := ctx.Value(fsctx.UploadPolicyCtx).(serializer.UploadPolicy)
@@ -209,6 +208,22 @@ func GenericAfterUpdate(ctx context.Context, fs *FileSystem) error {
return nil
}
// SlaveAfterUpload Slave模式下上传完成钩子
// TODO 测试
func SlaveAfterUpload(ctx context.Context, fs *FileSystem) error {
fileHeader := ctx.Value(fsctx.FileHeaderCtx).(FileHeader)
// 构造一个model.File用于生成缩略图
file := model.File{
Name: fileHeader.GetFileName(),
SourceName: ctx.Value(fsctx.SavePathCtx).(string),
}
fs.GenerateThumbnail(ctx, &file)
// TODO 发送回调请求
return nil
}
// GenericAfterUpload 文件上传完成后,包含数据库操作
func GenericAfterUpload(ctx context.Context, fs *FileSystem) error {
// 文件存放的虚拟路径