Feat: disable overwrite for non-updating put request, only works under local,slave,OneDrive,OSS policy. (#764)

This commit is contained in:
HFO4
2021-03-01 13:03:49 +08:00
parent c949d47161
commit 5e226efea1
16 changed files with 67 additions and 15 deletions

View File

@@ -235,8 +235,15 @@ func (handler Driver) Put(ctx context.Context, file io.ReadCloser, dst string, s
// 凭证有效期
credentialTTL := model.GetIntSetting("upload_credential_timeout", 3600)
// 是否允许覆盖
overwrite := true
if ctx.Value(fsctx.DisableOverwrite) != nil {
overwrite = false
}
options := []oss.Option{
oss.Expires(time.Now().Add(time.Duration(credentialTTL) * time.Second)),
oss.ForbidOverWrite(!overwrite),
}
// 上传文件