Skip to content

Commit

Permalink
fix(alist): use filebytes to upload file
Browse files Browse the repository at this point in the history
  • Loading branch information
krau committed Feb 1, 2025
1 parent 6c6ee77 commit e3f7380
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions storage/alist/alist.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e3f7380

Please sign in to comment.