From e3f7380341658a40ba16899d8442f299d980b545 Mon Sep 17 00:00:00 2001 From: krau <71133316+krau@users.noreply.github.com> Date: Sat, 1 Feb 2025 14:46:10 +0800 Subject: [PATCH] fix(alist): use filebytes to upload file --- storage/alist/alist.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/storage/alist/alist.go b/storage/alist/alist.go index fa590e3..4db73b1 100644 --- a/storage/alist/alist.go +++ b/storage/alist/alist.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "io" "net/http" "net/url" "os" @@ -107,11 +108,15 @@ func (a *Alist) Save(ctx context.Context, filePath, storagePath string) error { if err != nil { return err } + fileBytes, err := io.ReadAll(file) + if err != nil { + return err + } resp, err := reqClient.R(). SetContext(ctx). - SetBody(file). + SetBodyBytes(fileBytes). SetHeaders(map[string]string{ - "File-Path": url.PathEscape(storagePath), + "File-Path": url.QueryEscape(storagePath), "As-Task": "true", }).Put("/api/fs/put") if err != nil {