Feat: support apply append mode and overwrite mode for FileStream

This commit is contained in:
HFO4
2022-02-28 17:49:00 +08:00
parent 285611baf7
commit 118d738797
16 changed files with 32 additions and 41 deletions

View File

@@ -355,6 +355,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request, fs *filesyst
fs.Use("AfterValidateFailed", filesystem.HookCleanFileContent)
fs.Use("AfterValidateFailed", filesystem.HookClearFileSize)
ctx = context.WithValue(ctx, fsctx.FileModelCtx, *originFile)
fileData.Mode |= fsctx.Overwrite
} else {
// 给文件系统分配钩子
fs.Use("BeforeUpload", filesystem.HookValidateFile)
@@ -364,9 +365,6 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request, fs *filesyst
fs.Use("AfterUpload", filesystem.GenericAfterUpload)
fs.Use("AfterUpload", filesystem.HookGenerateThumb)
fs.Use("AfterValidateFailed", filesystem.HookDeleteTempFile)
// 禁止覆盖
fileData.Mode = fsctx.Create
}
// 执行上传