mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-09-07 16:46:37 +08:00
fix(alist): use filebytes to upload file
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@@ -107,11 +108,15 @@ func (a *Alist) Save(ctx context.Context, filePath, storagePath string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
fileBytes, err := io.ReadAll(file)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
resp, err := reqClient.R().
|
resp, err := reqClient.R().
|
||||||
SetContext(ctx).
|
SetContext(ctx).
|
||||||
SetBody(file).
|
SetBodyBytes(fileBytes).
|
||||||
SetHeaders(map[string]string{
|
SetHeaders(map[string]string{
|
||||||
"File-Path": url.PathEscape(storagePath),
|
"File-Path": url.QueryEscape(storagePath),
|
||||||
"As-Task": "true",
|
"As-Task": "true",
|
||||||
}).Put("/api/fs/put")
|
}).Put("/api/fs/put")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user