fix: not pass content length when uploading in non stream mode

This commit is contained in:
krau
2025-03-26 10:22:38 +08:00
parent 347a60f1f7
commit 7ffd9891a0
7 changed files with 144 additions and 111 deletions

View File

@@ -106,6 +106,12 @@ func (a *Alist) Save(ctx context.Context, reader io.Reader, storagePath string)
req.Header.Set("Authorization", a.token)
req.Header.Set("File-Path", url.PathEscape(storagePath))
req.Header.Set("Content-Type", "application/octet-stream")
if length := ctx.Value(types.ContextKeyContentLength); length != nil {
length, ok := length.(int64)
if ok {
req.ContentLength = length
}
}
resp, err := a.client.Do(req)
if err != nil {