|
|
@ -224,7 +224,16 @@ func (fs *FileSystem) CreateUploadSession(ctx context.Context, file *fsctx.FileS
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UploadFromStream 从文件流上传文件
|
|
|
|
// UploadFromStream 从文件流上传文件
|
|
|
|
func (fs *FileSystem) UploadFromStream(ctx context.Context, file *fsctx.FileStream) error {
|
|
|
|
func (fs *FileSystem) UploadFromStream(ctx context.Context, file *fsctx.FileStream, resetPolicy bool) error {
|
|
|
|
|
|
|
|
if resetPolicy {
|
|
|
|
|
|
|
|
// 重设存储策略
|
|
|
|
|
|
|
|
fs.Policy = &fs.User.Policy
|
|
|
|
|
|
|
|
err := fs.DispatchHandler()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 给文件系统分配钩子
|
|
|
|
// 给文件系统分配钩子
|
|
|
|
fs.Lock.Lock()
|
|
|
|
fs.Lock.Lock()
|
|
|
|
if fs.Hooks == nil {
|
|
|
|
if fs.Hooks == nil {
|
|
|
@ -242,16 +251,7 @@ func (fs *FileSystem) UploadFromStream(ctx context.Context, file *fsctx.FileStre
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UploadFromPath 将本机已有文件上传到用户的文件系统
|
|
|
|
// UploadFromPath 将本机已有文件上传到用户的文件系统
|
|
|
|
func (fs *FileSystem) UploadFromPath(ctx context.Context, src, dst string, resetPolicy bool, mode fsctx.WriteMode) error {
|
|
|
|
func (fs *FileSystem) UploadFromPath(ctx context.Context, src, dst string, mode fsctx.WriteMode) error {
|
|
|
|
// 重设存储策略
|
|
|
|
|
|
|
|
if resetPolicy {
|
|
|
|
|
|
|
|
fs.Policy = &fs.User.Policy
|
|
|
|
|
|
|
|
err := fs.DispatchHandler()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file, err := os.Open(util.RelativePath(src))
|
|
|
|
file, err := os.Open(util.RelativePath(src))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -273,5 +273,5 @@ func (fs *FileSystem) UploadFromPath(ctx context.Context, src, dst string, reset
|
|
|
|
Name: path.Base(dst),
|
|
|
|
Name: path.Base(dst),
|
|
|
|
VirtualPath: path.Dir(dst),
|
|
|
|
VirtualPath: path.Dir(dst),
|
|
|
|
Mode: mode,
|
|
|
|
Mode: mode,
|
|
|
|
})
|
|
|
|
}, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|