mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: file uploading in slave mode
This commit is contained in:
@@ -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 {
|
||||
// 文件存放的虚拟路径
|
||||
|
||||
Reference in New Issue
Block a user