chore(deps): use resty.dev/v3

This commit is contained in:
j2rong4cn
2025-07-03 21:19:55 +08:00
parent bea7a9b0e4
commit a73b345749
99 changed files with 248 additions and 244 deletions

View File

@ -9,7 +9,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/internal/setting"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func DelAdminCacheOnline() {
@ -42,8 +42,8 @@ func DelUserCacheOnline(username string) {
utils.Log.Warnf("[del_user_cache_online] failed: %+v", res.String())
return
}
code := utils.Json.Get(res.Body(), "code").ToInt()
msg := utils.Json.Get(res.Body(), "message").ToString()
code := utils.Json.Get(res.Bytes(), "code").ToInt()
msg := utils.Json.Get(res.Bytes(), "message").ToString()
if code != 200 {
utils.Log.Errorf("[del_user_cache_online] error: %s", msg)
return

View File

@ -22,8 +22,8 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Pan123 struct {
@ -115,7 +115,7 @@ func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
if res.StatusCode() == 302 {
link.URL = res.Header().Get("location")
} else if res.StatusCode() < 300 {
link.URL = utils.Json.Get(res.Body(), "data", "redirect_url").ToString()
link.URL = utils.Json.Get(res.Bytes(), "data", "redirect_url").ToString()
}
link.Header = http.Header{
"Referer": []string{"https://www.123pan.com/"},

View File

@ -11,7 +11,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *Pan123) getS3PreSignedUrls(ctx context.Context, upReq *UploadResp, start, end int) (*S3PreSignedURLs, error) {

View File

@ -15,9 +15,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -172,10 +172,10 @@ func (d *Pan123) login() error {
if err != nil {
return err
}
if utils.Json.Get(res.Body(), "code").ToInt() != 200 {
err = fmt.Errorf(utils.Json.Get(res.Body(), "message").ToString())
if utils.Json.Get(res.Bytes(), "code").ToInt() != 200 {
err = fmt.Errorf(utils.Json.Get(res.Bytes(), "message").ToString())
} else {
d.AccessToken = utils.Json.Get(res.Body(), "data", "token").ToString()
d.AccessToken = utils.Json.Get(res.Bytes(), "data", "token").ToString()
}
return err
}
@ -222,7 +222,7 @@ do:
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
code := utils.Json.Get(body, "code").ToInt()
if code != 0 {
if !isRetry && code == 401 {

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *Open123) create(parentFileID int64, filename string, etag string, size int64, duplicate int, containDir bool) (*UploadCreateResp, error) {

View File

@ -9,8 +9,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
var ( //不同情况下获取的AccessTokenQPS限制不同 如下模块化易于拓展
@ -56,7 +56,7 @@ func (d *Open123) Request(apiInfo *ApiInfo, method string, callback base.ReqCall
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
// 解析为通用响应
var baseResp BaseResp

View File

@ -17,8 +17,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Pan123Share struct {
@ -119,7 +119,7 @@ func (d *Pan123Share) Link(ctx context.Context, file model.Obj, args model.LinkA
if res.StatusCode() == 302 {
link.URL = res.Header().Get("location")
} else if res.StatusCode() < 300 {
link.URL = utils.Json.Get(res.Body(), "data", "redirect_url").ToString()
link.URL = utils.Json.Get(res.Bytes(), "data", "redirect_url").ToString()
}
link.Header = http.Header{
"Referer": []string{"https://www.123pan.com/"},

View File

@ -15,8 +15,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
const (
@ -76,7 +76,7 @@ func (d *Pan123Share) request(url string, method string, callback base.ReqCallba
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
code := utils.Json.Get(body, "code").ToInt()
if code != 0 {
return nil, errors.New(jsoniter.Get(body, "message").ToString())

View File

@ -17,9 +17,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -89,7 +89,7 @@ func (d *Yun139) refreshToken() error {
var resp RefreshTokenResp
reqBody := "<root><token>" + splits[2] + "</token><account>" + splits[1] + "</account><clienttype>656</clienttype></root>"
_, err = base.RestyClient.R().
ForceContentType("application/xml").
SetForceResponseContentType("application/xml").
SetBody(reqBody).
SetResult(&resp).
Post(url)
@ -150,12 +150,12 @@ func (d *Yun139) request(pathname string, method string, callback base.ReqCallba
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
err = utils.Json.Unmarshal(res.Bytes(), resp)
if err != nil {
return nil, err
}
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error) {
@ -207,12 +207,12 @@ func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
err = utils.Json.Unmarshal(res.Bytes(), resp)
if err != nil {
return nil, err
}
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Yun139) post(pathname string, data interface{}, resp interface{}) ([]byte, error) {
@ -500,12 +500,12 @@ func (d *Yun139) personalRequest(pathname string, method string, callback base.R
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
err = utils.Json.Unmarshal(res.Bytes(), resp)
if err != nil {
return nil, err
}
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Yun139) personalPost(pathname string, data interface{}, resp interface{}) ([]byte, error) {
return d.personalRequest(pathname, http.MethodPost, func(req *resty.Request) {

View File

@ -9,8 +9,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Cloud189 struct {
@ -52,7 +52,7 @@ func (d *Cloud189) Link(ctx context.Context, file model.Obj, args model.LinkArgs
if err != nil {
return nil, err
}
client := resty.NewWithClient(d.client.GetClient()).SetRedirectPolicy(
client := resty.NewWithClient(d.client.Client()).SetRedirectPolicy(
resty.RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}))

View File

@ -83,7 +83,7 @@ func (d *Cloud189) newLogin() error {
if err != nil {
return err
}
err = utils.Json.Unmarshal(res.Body(), &encryptConf)
err = utils.Json.Unmarshal(res.Bytes(), &encryptConf)
if err != nil {
return err
}
@ -118,9 +118,9 @@ func (d *Cloud189) newLogin() error {
return err
}
log.Debugf("189 login resp body: %s", res.String())
loginResult := utils.Json.Get(res.Body(), "result").ToInt()
loginResult := utils.Json.Get(res.Bytes(), "result").ToInt()
if loginResult != 0 {
return errors.New(utils.Json.Get(res.Body(), "msg").ToString())
return errors.New(utils.Json.Get(res.Bytes(), "msg").ToString())
}
return nil
}

View File

@ -20,9 +20,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
myrand "github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -81,7 +81,7 @@ import (
// // Enter the verification code manually
// //err = message.GetMessenger().WaitSend(message.Message{
// // Type: "image",
// // Content: "data:image/png;base64," + base64.StdEncoding.EncodeToString(imgRes.Body()),
// // Content: "data:image/png;base64," + base64.StdEncoding.EncodeToString(imgRes.Body),
// //}, 10)
// //if err != nil {
// // return err
@ -89,15 +89,15 @@ import (
// //vCodeRS, err = message.GetMessenger().WaitReceive(30)
// // use ocr api
// vRes, err := base.RestyClient.R().SetMultipartField(
// "image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Body())).
// "image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Body)).
// Post(setting.GetStr(conf.OcrApi))
// if err != nil {
// return err
// }
// if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
// return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
// if jsoniter.Get(vRes.Bytes(), "status").ToInt() != 200 {
// return errors.New("ocr error:" + jsoniter.Get(vRes.Bytes(), "msg").ToString())
// }
// vCodeRS = jsoniter.Get(vRes.Body(), "result").ToString()
// vCodeRS = jsoniter.Get(vRes.Bytes(), "result").ToString()
// log.Debugln("code: ", vCodeRS)
// }
// userRsa := RsaEncode([]byte(d.Username), jRsakey, true)
@ -128,7 +128,7 @@ import (
// if err != nil {
// return err
// }
// err = utils.Json.Unmarshal(res.Body(), &loginResp)
// err = utils.Json.Unmarshal(res.Bytes(), &loginResp)
// if err != nil {
// log.Error(err.Error())
// return err
@ -167,10 +167,10 @@ func (d *Cloud189) request(url string, method string, callback base.ReqCallback,
return d.request(url, method, callback, resp)
}
}
if jsoniter.Get(res.Body(), "res_code").ToInt() != 0 {
err = errors.New(jsoniter.Get(res.Body(), "res_message").ToString())
if jsoniter.Get(res.Bytes(), "res_code").ToInt() != 0 {
err = errors.New(jsoniter.Get(res.Bytes(), "res_message").ToString())
}
return res.Body(), err
return res.Bytes(), err
}
func (d *Cloud189) getFiles(fileId string) ([]model.Obj, error) {
@ -232,7 +232,7 @@ func (d *Cloud189) oldUpload(dstDir model.Obj, file model.FileStreamer) error {
if err != nil {
return err
}
if utils.Json.Get(res.Body(), "MD5").ToString() != "" {
if utils.Json.Get(res.Bytes(), "MD5").ToString() != "" {
return nil
}
log.Debugf(res.String())
@ -297,7 +297,7 @@ func (d *Cloud189) uploadRequest(uri string, form map[string]string, resp interf
if err != nil {
return nil, err
}
data = res.Body()
data = res.Bytes()
if utils.Json.Get(data, "code").ToString() != "SUCCESS" {
return nil, errors.New(uri + "---" + jsoniter.Get(data, "msg").ToString())
}

View File

@ -12,7 +12,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Cloud189TV struct {
@ -126,7 +126,7 @@ func (y *Cloud189TV) Link(ctx context.Context, file model.Obj, args model.LinkAr
if err != nil {
return nil, err
}
defer res.RawBody().Close()
defer res.Body.Close()
if res.StatusCode() == 302 {
downloadUrl.URL = res.Header().Get("location")
}

View File

@ -5,23 +5,24 @@ import (
"encoding/base64"
"encoding/xml"
"fmt"
"github.com/skip2/go-qrcode"
"io"
"net/http"
"strconv"
"strings"
"time"
"github.com/skip2/go-qrcode"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"resty.dev/v3"
)
const (
@ -96,7 +97,7 @@ func (y *Cloud189TV) request(url, method string, callback base.ReqCallback, para
if erron.HasError() {
return nil, &erron
}
return res.Body(), nil
return res.Bytes(), nil
}
func (y *Cloud189TV) get(url string, callback base.ReqCallback, resp interface{}, isFamily ...bool) ([]byte, error) {

View File

@ -13,8 +13,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
"resty.dev/v3"
)
type Cloud189PC struct {
@ -171,7 +171,7 @@ func (y *Cloud189PC) Link(ctx context.Context, file model.Obj, args model.LinkAr
if err != nil {
return nil, err
}
defer res.RawBody().Close()
defer res.Body.Close()
if res.StatusCode() == 302 {
downloadUrl.URL = res.Header().Get("location")
}

View File

@ -30,10 +30,10 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"resty.dev/v3"
)
const (
@ -129,7 +129,7 @@ func (y *Cloud189PC) request(url, method string, callback base.ReqCallback, para
if erron.HasError() {
return nil, &erron
}
return res.Body(), nil
return res.Bytes(), nil
}
func (y *Cloud189PC) get(url string, callback base.ReqCallback, resp interface{}, isFamily ...bool) ([]byte, error) {
@ -287,7 +287,7 @@ func (y *Cloud189PC) login() (err error) {
param := y.loginParam
var loginresp LoginResp
_, err = y.client.R().
ForceContentType("application/json;charset=UTF-8").SetResult(&loginresp).
SetForceResponseContentType("application/json;charset=UTF-8").SetResult(&loginresp).
SetHeaders(map[string]string{
"REQID": param.ReqId,
"lt": param.Lt,
@ -370,7 +370,7 @@ func (y *Cloud189PC) initLoginParam() error {
// 获取rsa公钥
var encryptConf EncryptConfResp
_, err = y.client.R().
ForceContentType("application/json;charset=UTF-8").SetResult(&encryptConf).
SetForceResponseContentType("application/json;charset=UTF-8").SetResult(&encryptConf).
SetFormData(map[string]string{"appId": APP_ID}).
Post(AUTH_URL + "/api/logbox/config/encryptConf.do")
if err != nil {
@ -411,19 +411,19 @@ func (y *Cloud189PC) initLoginParam() error {
if imgRes.Size() > 20 {
if setting.GetStr(conf.OcrApi) != "" && !y.NoUseOcr {
vRes, err := base.RestyClient.R().
SetMultipartField("image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Body())).
SetMultipartField("image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Bytes())).
Post(setting.GetStr(conf.OcrApi))
if err != nil {
return err
}
if jsoniter.Get(vRes.Body(), "status").ToInt() == 200 {
y.VCode = jsoniter.Get(vRes.Body(), "result").ToString()
if jsoniter.Get(vRes.Bytes(), "status").ToInt() == 200 {
y.VCode = jsoniter.Get(vRes.Bytes(), "result").ToString()
return nil
}
}
// 返回验证码图片给前端
return fmt.Errorf(`need img validate code: <img src="data:image/png;base64,%s"/>`, base64.StdEncoding.EncodeToString(imgRes.Body()))
return fmt.Errorf(`need img validate code: <img src="data:image/png;base64,%s"/>`, base64.StdEncoding.EncodeToString(imgRes.Bytes()))
}
return nil
}

View File

@ -22,8 +22,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type AliDrive struct {

View File

@ -11,8 +11,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/dustinxie/ecc"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
"resty.dev/v3"
)
func (d *AliDrive) createSession() error {
@ -134,7 +134,7 @@ func (d *AliDrive) request(url, method string, callback base.ReqCallback, resp i
} else if res.IsError() {
return nil, errors.New("bad status code " + res.Status()), e
}
return res.Body(), nil, e
return res.Bytes(), nil, e
}
func (d *AliDrive) getFiles(fileId string) ([]File, error) {

View File

@ -14,8 +14,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/rateg"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type AliyundriveOpen struct {

View File

@ -18,8 +18,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
func makePartInfos(size int) []base.Json {

View File

@ -13,8 +13,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -73,7 +73,7 @@ func (d *AliyundriveOpen) _refreshToken() (string, string, error) {
if e.Code != "" {
return "", "", fmt.Errorf("failed to refresh token: %s", e.Message)
}
refresh, access := utils.Json.Get(res.Body(), "refresh_token").ToString(), utils.Json.Get(res.Body(), "access_token").ToString()
refresh, access := utils.Json.Get(res.Bytes(), "refresh_token").ToString(), utils.Json.Get(res.Bytes(), "access_token").ToString()
if refresh == "" {
return "", "", fmt.Errorf("failed to refresh token: refresh token is empty, resp: %s", res.String())
}
@ -160,7 +160,7 @@ func (d *AliyundriveOpen) requestReturnErrResp(uri, method string, callback base
}
return nil, fmt.Errorf("%s:%s", e.Code, e.Message), &e
}
return res.Body(), nil, nil
return res.Bytes(), nil, nil
}
func (d *AliyundriveOpen) list(ctx context.Context, data base.Json) (*Files, error) {

View File

@ -13,8 +13,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/rateg"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type AliyundriveShare struct {

View File

@ -90,7 +90,7 @@ func (d *AliyundriveShare) request(url, method string, callback base.ReqCallback
return nil, errors.New(e.Code + ": " + e.Message)
}
}
return resp.Body(), nil
return resp.Bytes(), nil
}
func (d *AliyundriveShare) getFiles(fileId string) ([]File, error) {

View File

@ -355,8 +355,8 @@ func (d *BaiduNetdisk) uploadSlice(ctx context.Context, params map[string]string
return err
}
log.Debugln(res.RawResponse.Status + res.String())
errCode := utils.Json.Get(res.Body(), "error_code").ToInt()
errNo := utils.Json.Get(res.Body(), "errno").ToInt()
errCode := utils.Json.Get(res.Bytes(), "error_code").ToInt()
errNo := utils.Json.Get(res.Bytes(), "errno").ToInt()
if errCode != 0 || errNo != 0 {
return errs.NewErr(errs.StreamIncomplete, "error in uploading to baidu, will retry. response=%s", res.String())
}

View File

@ -16,8 +16,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -110,7 +110,7 @@ func (d *BaiduNetdisk) request(furl string, method string, callback base.ReqCall
return err
}
log.Debugf("[baidu_netdisk] req: %s, resp: %s", furl, res.String())
errno := utils.Json.Get(res.Body(), "errno").ToInt()
errno := utils.Json.Get(res.Bytes(), "errno").ToInt()
if errno != 0 {
if utils.SliceContains([]int{111, -6}, errno) {
log.Info("refreshing baidu_netdisk token.")
@ -121,13 +121,13 @@ func (d *BaiduNetdisk) request(furl string, method string, callback base.ReqCall
}
if 31023 == errno && d.DownloadAPI == "crack_video" {
result = res.Body()
result = res.Bytes()
return nil
}
return fmt.Errorf("req: [%s] ,errno: %d, refer to https://pan.baidu.com/union/doc/", furl, errno)
}
result = res.Body()
result = res.Bytes()
return nil
},
retry.LastErrorOnly(true),

View File

@ -21,7 +21,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/errgroup"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type BaiduPhoto struct {

View File

@ -12,7 +12,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
const (
@ -38,7 +38,7 @@ func (d *BaiduPhoto) Request(client *resty.Client, furl string, method string, c
return nil, err
}
erron := utils.Json.Get(res.Body(), "errno").ToInt()
erron := utils.Json.Get(res.Bytes(), "errno").ToInt()
switch erron {
case 0:
break
@ -63,7 +63,7 @@ func (d *BaiduPhoto) Request(client *resty.Client, furl string, method string, c
// if err != nil {
// return nil, err
// }
// return res.Body(), nil
// return res.Bytes(), nil
//}
// func (d *BaiduPhoto) refreshToken() error {

View File

@ -7,7 +7,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/conf"
"github.com/OpenListTeam/OpenList/v4/internal/net"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
var (
@ -34,7 +34,6 @@ func NewRestyClient() *resty.Client {
client := resty.New().
SetHeader("user-agent", UserAgent).
SetRetryCount(3).
SetRetryResetReaders(true).
SetTimeout(DefaultTimeout).
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify})
return client

View File

@ -1,6 +1,6 @@
package base
import "github.com/go-resty/resty/v2"
import "resty.dev/v3"
type Json map[string]interface{}

View File

@ -19,8 +19,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"google.golang.org/appengine/log"
"resty.dev/v3"
)
type ChaoXing struct {

View File

@ -12,7 +12,7 @@ import (
"strings"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *ChaoXing) requestDownload(pathname string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
@ -35,7 +35,7 @@ func (d *ChaoXing) requestDownload(pathname string, method string, callback base
if err != nil {
return nil, err
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *ChaoXing) request(pathname string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
@ -61,7 +61,7 @@ func (d *ChaoXing) request(pathname string, method string, callback base.ReqCall
if err != nil {
return nil, err
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *ChaoXing) GetFiles(parent string) ([]File, error) {

View File

@ -12,7 +12,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Cloudreve struct {

View File

@ -20,8 +20,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/setting"
"github.com/OpenListTeam/OpenList/v4/pkg/cookie"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -134,10 +134,10 @@ func (d *Cloudreve) doLogin(needCaptcha bool) error {
if err != nil {
return err
}
if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
if jsoniter.Get(vRes.Bytes(), "status").ToInt() != 200 {
return errors.New("ocr error:" + jsoniter.Get(vRes.Bytes(), "msg").ToString())
}
captchaCode = jsoniter.Get(vRes.Body(), "result").ToString()
captchaCode = jsoniter.Get(vRes.Bytes(), "result").ToString()
}
var resp Resp
err = d.request(http.MethodPost, loginPath, func(req *resty.Request) {
@ -206,7 +206,7 @@ func (d *Cloudreve) upLocal(ctx context.Context, stream model.FileStreamer, u Up
req.SetHeader("Content-Length", strconv.FormatInt(byteSize, 10))
req.SetHeader("User-Agent", d.getUA())
req.SetBody(driver.NewLimitedUploadStream(ctx, bytes.NewReader(byteData)))
req.AddRetryCondition(func(r *resty.Response, err error) bool {
req.AddRetryConditions(func(r *resty.Response, err error) bool {
if err != nil {
return true
}
@ -214,7 +214,7 @@ func (d *Cloudreve) upLocal(ctx context.Context, stream model.FileStreamer, u Up
return true
}
var retryResp Resp
jErr := base.RestyClient.JSONUnmarshal(r.Body(), &retryResp)
jErr := utils.Json.Unmarshal(r.Bytes(), &retryResp)
if jErr != nil {
return true
}

View File

@ -14,7 +14,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type CloudreveV4 struct {

View File

@ -20,8 +20,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/internal/setting"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -153,10 +153,10 @@ func (d *CloudreveV4) doLogin(needCaptcha bool) error {
if err != nil {
return err
}
if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
if jsoniter.Get(vRes.Bytes(), "status").ToInt() != 200 {
return errors.New("ocr error:" + jsoniter.Get(vRes.Bytes(), "msg").ToString())
}
captchaCode := jsoniter.Get(vRes.Body(), "result").ToString()
captchaCode := jsoniter.Get(vRes.Bytes(), "result").ToString()
if captchaCode == "" {
return errors.New("ocr error: empty result")
}
@ -224,7 +224,7 @@ func (d *CloudreveV4) upLocal(ctx context.Context, file model.FileStreamer, u Fi
req.SetContentLength(true)
req.SetHeader("Content-Length", strconv.FormatInt(byteSize, 10))
req.SetBody(driver.NewLimitedUploadStream(ctx, bytes.NewReader(byteData)))
req.AddRetryCondition(func(r *resty.Response, err error) bool {
req.AddRetryConditions(func(r *resty.Response, err error) bool {
if err != nil {
return true
}
@ -232,7 +232,7 @@ func (d *CloudreveV4) upLocal(ctx context.Context, file model.FileStreamer, u Fi
return true
}
var retryResp Resp
jErr := base.RestyClient.JSONUnmarshal(r.Body(), &retryResp)
jErr := utils.Json.Unmarshal(r.Bytes(), &retryResp)
if jErr != nil {
return true
}

View File

@ -13,8 +13,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
"resty.dev/v3"
)
type Doubao struct {

View File

@ -27,9 +27,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/errgroup"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
const (
@ -83,7 +83,7 @@ func (d *Doubao) request(path string, method string, callback base.ReqCallback,
return nil, err
}
body := res.Body()
body := res.Bytes()
// 先解析为通用响应
if err = json.Unmarshal(body, &commonResp); err != nil {
return nil, err
@ -205,7 +205,7 @@ func (d *Doubao) signRequest(req *resty.Request, method, tokenType, uploadUrl st
}
// 查询参数按照字母顺序排序
canonicalQueryString := getCanonicalQueryString(req.QueryParam)
canonicalQueryString := getCanonicalQueryString(req.QueryParams)
// 规范请求头
canonicalHeaders, signedHeaders := getCanonicalHeadersFromMap(req.Header)
canonicalRequest := method + "\n" +
@ -270,7 +270,7 @@ func (d *Doubao) requestApi(url, method, tokenType string, callback base.ReqCall
return nil, err
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Doubao) initUploadToken() (*UploadToken, error) {
@ -655,7 +655,7 @@ func (d *Doubao) uploadRequest(uploadUrl string, method string, storeInfo StoreI
return nil, fmt.Errorf("upload request failed: %w", err)
}
return res.Body(), nil
return res.Bytes(), nil
}
// 初始化分片上传

View File

@ -10,7 +10,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type DoubaoShare struct {

View File

@ -12,8 +12,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
const (
@ -72,7 +72,7 @@ func (d *DoubaoShare) request(path string, method string, callback base.ReqCallb
return nil, err
}
body := res.Body()
body := res.Bytes()
// 先解析为通用响应
if err = json.Unmarshal(body, &commonResp); err != nil {
return nil, err

View File

@ -12,8 +12,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Dropbox struct {

View File

@ -10,8 +10,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
func (d *Dropbox) refreshToken() error {
@ -112,7 +112,7 @@ func (d *Dropbox) request(uri, method string, callback base.ReqCallback, retry .
}
return nil, fmt.Errorf("%s:%s", e.Error, e.ErrorSummary)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Dropbox) list(ctx context.Context, data base.Json, isContinue bool) (*ListResp, error) {

View File

@ -9,7 +9,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *FebBox) refreshTokenByOAuth2() error {
@ -48,9 +48,9 @@ func (d *FebBox) request(url string, method string, callback base.ReqCallback, r
switch e.ErrorCode {
case 0:
return res.Body(), nil
return res.Bytes(), nil
case 1:
return res.Body(), nil
return res.Bytes(), nil
case -10001:
if e.ServerName != "" {
// access_token 过期

View File

@ -17,9 +17,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/go-resty/resty/v2"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Github struct {
@ -680,7 +680,7 @@ func (d *Github) get(path string) (*Object, error) {
return nil, toErr(res)
}
var resp Object
err = utils.Json.Unmarshal(res.Body(), &resp)
err = utils.Json.Unmarshal(res.Bytes(), &resp)
return &resp, err
}
@ -780,7 +780,7 @@ func (d *Github) getTree(sha string) (*TreeResp, error) {
return nil, toErr(res)
}
var resp TreeResp
if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), &resp); err != nil {
return nil, err
}
return &resp, nil
@ -818,7 +818,7 @@ func (d *Github) newTree(baseSha string, tree []interface{}) (string, error) {
return "", toErr(res)
}
var resp TreeResp
if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), &resp); err != nil {
return "", err
}
return resp.Sha, nil
@ -847,7 +847,7 @@ func (d *Github) commit(message, treeSha string) error {
return toErr(res)
}
var resp CommitResp
if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), &resp); err != nil {
return err
}
@ -876,7 +876,7 @@ func (d *Github) getBranchHead() (string, error) {
return "", toErr(res)
}
var resp BranchResp
if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), &resp); err != nil {
return "", err
}
return resp.Commit.Sha, nil
@ -936,7 +936,7 @@ func (d *Github) getRepo() (*RepoResp, error) {
return nil, toErr(res)
}
var resp RepoResp
if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), &resp); err != nil {
return nil, err
}
return &resp, nil
@ -951,7 +951,7 @@ func (d *Github) getAuthenticatedUser() (*UserResp, error) {
return nil, toErr(res)
}
resp := &UserResp{}
if err = utils.Json.Unmarshal(res.Body(), resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), resp); err != nil {
return nil, err
}
return resp, nil

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp/armor"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type MessageTemplateVars struct {
@ -40,7 +40,7 @@ func calculateBase64Length(inputLength int64) int64 {
func toErr(res *resty.Response) error {
var errMsg ErrResp
if err := utils.Json.Unmarshal(res.Body(), &errMsg); err != nil {
if err := utils.Json.Unmarshal(res.Bytes(), &errMsg); err != nil {
return errors.New(res.Status())
} else {
return fmt.Errorf("%s: %s", res.Status(), errMsg.Message)

View File

@ -6,7 +6,7 @@ import (
"time"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type MountPoint struct {
@ -26,7 +26,7 @@ func (m *MountPoint) RequestRelease(get func(url string) (*resty.Response, error
if m.Release == nil || refresh {
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/releases/latest")
m.Release = new(Release)
json.Unmarshal(resp.Body(), m.Release)
json.Unmarshal(resp.Bytes(), m.Release)
}
}
@ -39,7 +39,7 @@ func (m *MountPoint) RequestReleases(get func(url string) (*resty.Response, erro
if m.Releases == nil || refresh {
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/releases")
m.Releases = new([]Release)
json.Unmarshal(resp.Body(), m.Releases)
json.Unmarshal(resp.Bytes(), m.Releases)
}
}
@ -147,7 +147,7 @@ func (m *MountPoint) GetOtherFile(get func(url string) (*resty.Response, error),
if m.OtherFile == nil || refresh {
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/contents")
m.OtherFile = new([]FileInfo)
json.Unmarshal(resp.Body(), m.OtherFile)
json.Unmarshal(resp.Bytes(), m.OtherFile)
}
files := make([]File, 0)

View File

@ -6,8 +6,8 @@ import (
"strings"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// 发送 GET 请求

View File

@ -11,7 +11,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type GoogleDrive struct {

View File

@ -17,9 +17,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"github.com/golang-jwt/jwt/v4"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -215,7 +215,7 @@ func (d *GoogleDrive) request(url string, method string, callback base.ReqCallba
}
return nil, fmt.Errorf("%s: %v", e.Error.Message, e.Error.Errors)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *GoogleDrive) getFiles(id string) ([]File, error) {

View File

@ -12,7 +12,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type GooglePhoto struct {

View File

@ -5,7 +5,7 @@ import (
"net/http"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -68,7 +68,7 @@ func (d *GooglePhoto) request(url string, method string, callback base.ReqCallba
}
return nil, fmt.Errorf("%s: %v", e.Error.Message, e.Error.Errors)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *GooglePhoto) getFiles(id string) ([]MediaItem, error) {

View File

@ -19,8 +19,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/foxxorcat/mopan-sdk-go"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type ILanZou struct {
@ -166,7 +166,7 @@ func (d *ILanZou) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
if res.StatusCode() == 302 {
realURL = res.Header().Get("location")
} else {
return nil, fmt.Errorf("redirect failed, status: %d, msg: %s", res.StatusCode(), utils.Json.Get(res.Body(), "msg").ToString())
return nil, fmt.Errorf("redirect failed, status: %d, msg: %s", res.StatusCode(), utils.Json.Get(res.Bytes(), "msg").ToString())
}
link := model.Link{URL: realURL}
return &link, nil
@ -316,14 +316,14 @@ func (d *ILanZou) Put(ctx context.Context, dstDir model.Obj, s model.FileStreame
if err != nil {
return nil, err
}
token = utils.Json.Get(res.Body(), "token").ToString()
token = utils.Json.Get(res.Bytes(), "token").ToString()
} else {
keyBase64 := base64.URLEncoding.EncodeToString([]byte(key))
res, err := d.upClient.R().SetHeader("Authorization", "UpToken "+upToken).Post(fmt.Sprintf("https://upload.qiniup.com/buckets/%s/objects/%s/uploads", d.conf.bucket, keyBase64))
if err != nil {
return nil, err
}
uploadId := utils.Json.Get(res.Body(), "uploadId").ToString()
uploadId := utils.Json.Get(res.Bytes(), "uploadId").ToString()
parts := make([]Part, 0)
partNum := (s.GetSize() + DefaultPartSize - 1) / DefaultPartSize
for i := 1; i <= int(partNum); i++ {
@ -332,7 +332,7 @@ func (d *ILanZou) Put(ctx context.Context, dstDir model.Obj, s model.FileStreame
if err != nil {
return nil, err
}
etag := utils.Json.Get(res.Body(), "etag").ToString()
etag := utils.Json.Get(res.Bytes(), "etag").ToString()
parts = append(parts, Part{
PartNumber: i,
ETag: etag,
@ -345,7 +345,7 @@ func (d *ILanZou) Put(ctx context.Context, dstDir model.Obj, s model.FileStreame
if err != nil {
return nil, err
}
token = utils.Json.Get(res.Body(), "token").ToString()
token = utils.Json.Get(res.Bytes(), "token").ToString()
}
// commit upload
var resp UploadResultResp

View File

@ -12,8 +12,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/foxxorcat/mopan-sdk-go"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
func (d *ILanZou) login() error {
@ -92,7 +92,7 @@ func (d *ILanZou) request(pathname, method string, callback base.ReqCallback, pr
return nil, err
}
isRetry := len(retry) > 0 && retry[0]
body := res.Body()
body := res.Bytes()
code := utils.Json.Get(body, "code").ToInt()
msg := utils.Json.Get(body, "msg").ToString()
if code != 200 {

View File

@ -11,7 +11,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type KodBox struct {

View File

@ -6,7 +6,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *KodBox) getToken() error {
@ -62,7 +62,7 @@ func (d *KodBox) request(method string, pathname string, callback base.ReqCallba
return nil, err
}
err := utils.Json.Unmarshal(res.Body(), &commonResp)
err := utils.Json.Unmarshal(res.Bytes(), &commonResp)
if err != nil {
return nil, err
}
@ -83,5 +83,5 @@ func (d *KodBox) request(method string, pathname string, callback base.ReqCallba
if commonResp.Code.(bool) == false {
return nil, fmt.Errorf("request failed: %s", commonResp.Data)
}
return res.Body(), nil
return res.Bytes(), nil
}

View File

@ -9,7 +9,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type LanZou struct {

View File

@ -16,8 +16,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
var upClient *resty.Client
@ -62,8 +62,8 @@ func (d *LanZou) post(url string, callback base.ReqCallback, resp interface{}) (
func (d *LanZou) _post(url string, callback base.ReqCallback, resp interface{}, up bool) ([]byte, error) {
data, err := d.request(url, http.MethodPost, func(req *resty.Request) {
req.AddRetryCondition(func(r *resty.Response, err error) bool {
if utils.Json.Get(r.Body(), "zt").ToInt() == 4 {
req.AddRetryConditions(func(r *resty.Response, err error) bool {
if utils.Json.Get(r.Bytes(), "zt").ToInt() == 4 {
time.Sleep(time.Second)
return true
}
@ -123,7 +123,7 @@ func (d *LanZou) request(url string, method string, callback base.ReqCallback, u
return nil, err
}
log.Debugf("lanzou request: url=>%s ,stats=>%d ,body => %s\n", res.Request.URL, res.StatusCode(), res.String())
return res.Body(), err
return res.Bytes(), err
}
func (d *LanZou) Login() ([]*http.Cookie, error) {
@ -141,8 +141,8 @@ func (d *LanZou) Login() ([]*http.Cookie, error) {
if err != nil {
return nil, err
}
if utils.Json.Get(resp.Body(), "zt").ToInt() != 1 {
return nil, fmt.Errorf("login err: %s", resp.Body())
if utils.Json.Get(resp.Bytes(), "zt").ToInt() != 1 {
return nil, fmt.Errorf("login err: %s", resp.Bytes())
}
d.Cookie = CookieToString(resp.Cookies())
return resp.Cookies(), nil

View File

@ -5,7 +5,7 @@ import (
"net/http"
"time"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/errs"

View File

@ -27,7 +27,7 @@ func (d *LenovoNasShare) request(url string, method string, callback base.ReqCal
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
result := utils.Json.Get(body, "result").ToBool()
if !result {
return nil, errors.New(jsoniter.Get(body, "error", "msg").ToString())

View File

@ -18,9 +18,9 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type MediaTrack struct {

View File

@ -8,8 +8,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -31,9 +31,9 @@ func (d *MediaTrack) request(url string, method string, callback base.ReqCallbac
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
err = utils.Json.Unmarshal(res.Bytes(), resp)
}
return res.Body(), err
return res.Bytes(), err
}
func (d *MediaTrack) getFiles(parentId string) ([]File, error) {

View File

@ -6,7 +6,7 @@ import (
"io"
"time"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/driver"

View File

@ -143,9 +143,7 @@ func (d *MoPan) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
if err != nil {
return nil, err
}
defer func() {
_ = res.RawBody().Close()
}()
defer res.Body.Close()
if res.StatusCode() == 302 {
data.DownloadUrl = res.Header().Get("location")
}

View File

@ -79,7 +79,7 @@ func (d *NeteaseMusic) request(url, method string, opt ReqOption) ([]byte, error
if err != nil {
return nil, err
}
return res.Body(), nil
return res.Bytes(), nil
}
if method == http.MethodGet {
@ -87,7 +87,7 @@ func (d *NeteaseMusic) request(url, method string, opt ReqOption) ([]byte, error
if err != nil {
return nil, err
}
return res.Body(), nil
return res.Bytes(), nil
}
return nil, errs.NotImplement

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Onedrive struct {

View File

@ -16,8 +16,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
var onedriveHostMap = map[string]Host{
@ -157,7 +157,7 @@ func (d *Onedrive) Request(url string, method string, callback base.ReqCallback,
}
return nil, errors.New(e.Error.Message)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Onedrive) getFiles(path string) ([]File, error) {

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type OnedriveAPP struct {

View File

@ -16,8 +16,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
var onedriveHostMap = map[string]Host{
@ -112,7 +112,7 @@ func (d *OnedriveAPP) Request(url string, method string, callback base.ReqCallba
}
return nil, errors.New(e.Error.Message)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *OnedriveAPP) getFiles(path string) ([]File, error) {

View File

@ -16,8 +16,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/server/common"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type OpenList struct {
@ -62,7 +62,7 @@ func (d *OpenList) Init(ctx context.Context) error {
if err != nil {
return err
}
allowMounted := utils.Json.Get(res.Body(), "data", conf.AllowMounted).ToString() == "true"
allowMounted := utils.Json.Get(res.Bytes(), "data", conf.AllowMounted).ToString() == "true"
if !allowMounted {
return fmt.Errorf("the site does not allow mounted")
}

View File

@ -8,8 +8,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/server/common"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
func (d *OpenList) login() error {
@ -50,7 +50,7 @@ func (d *OpenList) request(api, method string, callback base.ReqCallback, retry
if res.StatusCode() >= 400 {
return nil, res.StatusCode(), fmt.Errorf("request failed, status: %s", res.Status())
}
code := utils.Json.Get(res.Body(), "code").ToInt()
code := utils.Json.Get(res.Bytes(), "code").ToInt()
if code != 200 {
if (code == 401 || code == 403) && !utils.IsBool(retry...) {
err = d.login()
@ -59,7 +59,7 @@ func (d *OpenList) request(api, method string, callback base.ReqCallback, retry
}
return d.request(api, method, callback, true)
}
return nil, code, fmt.Errorf("request failed,code: %d, message: %s", code, utils.Json.Get(res.Body(), "message").ToString())
return nil, code, fmt.Errorf("request failed,code: %d, message: %s", code, utils.Json.Get(res.Bytes(), "message").ToString())
}
return res.Body(), 200, nil
return res.Bytes(), 200, nil
}

View File

@ -14,8 +14,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
hash_extend "github.com/OpenListTeam/OpenList/v4/pkg/utils/hash"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type PikPak struct {

View File

@ -22,9 +22,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"resty.dev/v3"
)
var AndroidAlgorithms = []string{
@ -121,7 +121,7 @@ func (d *PikPak) login() error {
if e.ErrorCode != 0 {
return &e
}
data := res.Body()
data := res.Bytes()
d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
d.AccessToken = jsoniter.Get(data, "access_token").ToString()
d.Common.SetUserID(jsoniter.Get(data, "sub").ToString())
@ -157,7 +157,7 @@ func (d *PikPak) refreshToken(refreshToken string) error {
op.MustSaveDriverStorage(d)
return errors.New(e.Error())
}
data := res.Body()
data := res.Bytes()
d.Status = "work"
d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
d.AccessToken = jsoniter.Get(data, "access_token").ToString()
@ -194,7 +194,7 @@ func (d *PikPak) request(url string, method string, callback base.ReqCallback, r
switch e.ErrorCode {
case 0:
return res.Body(), nil
return res.Bytes(), nil
case 4122, 4121, 16:
// access_token 过期
if err1 := d.refreshToken(d.RefreshToken); err1 != nil {

View File

@ -10,7 +10,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type PikPakShare struct {

View File

@ -14,7 +14,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
var AndroidAlgorithms = []string{
@ -100,7 +100,7 @@ func (d *PikPakShare) request(url string, method string, callback base.ReqCallba
}
switch e.ErrorCode {
case 0:
return res.Body(), nil
return res.Bytes(), nil
case 9: // 验证码token过期
if err = d.RefreshCaptchaToken(GetAction(method, url), ""); err != nil {
return nil, err

View File

@ -6,16 +6,17 @@ import (
"encoding/hex"
"errors"
"fmt"
"hash"
"io"
"net/http"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"hash"
"io"
"net/http"
"resty.dev/v3"
)
type QuarkOpen struct {

View File

@ -8,19 +8,20 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/google/uuid"
"io"
"net/http"
"strconv"
"strings"
"time"
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/google/uuid"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
func (d *QuarkOpen) request(ctx context.Context, pathname string, method string, callback base.ReqCallback, resp interface{}, manualSign ...*ManualSign) ([]byte, error) {
@ -79,7 +80,7 @@ func (d *QuarkOpen) request(ctx context.Context, pathname string, method string,
return nil, errors.New(e.ErrorInfo)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *QuarkOpen) GetFiles(ctx context.Context, parent string) ([]File, error) {

View File

@ -15,8 +15,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type QuarkOrUC struct {

View File

@ -17,8 +17,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/cookie"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -62,7 +62,7 @@ func (d *QuarkOrUC) request(pathname string, method string, callback base.ReqCal
if e.Status >= 400 || e.Code != 0 {
return nil, errors.New(e.Message)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *QuarkOrUC) GetFiles(parent string) ([]model.Obj, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/errs"

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
const (
@ -82,7 +82,7 @@ func (d *QuarkUCTV) request(ctx context.Context, pathname string, method string,
if e.Status >= 400 || e.Errno != 0 {
return nil, errors.New(e.ErrorInfo)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *QuarkUCTV) getLoginCode(ctx context.Context) (string, error) {

View File

@ -10,7 +10,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Seafile struct {

View File

@ -11,7 +11,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *Seafile) getToken() error {
@ -68,7 +68,7 @@ func (d *Seafile) request(method string, pathname string, callback base.ReqCallb
if res.StatusCode() >= 400 {
return nil, fmt.Errorf("request failed: %s", res.String())
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Seafile) getRepoAndPath(fullPath string) (repo *LibraryInfo, path string, err error) {

View File

@ -10,7 +10,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Teambition struct {

View File

@ -18,8 +18,8 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -50,7 +50,7 @@ func (d *Teambition) request(pathname string, method string, callback base.ReqCa
if e.Name != "" {
return nil, errors.New(e.Message)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Teambition) getFiles(parentId string) ([]model.Obj, error) {

View File

@ -136,7 +136,7 @@ func (d *Terabox) Put(ctx context.Context, dstDir model.Obj, stream model.FileSt
return err
}
var locateupload_resp LocateUploadResp
err = utils.Json.Unmarshal(resp.Body(), &locateupload_resp)
err = utils.Json.Unmarshal(resp.Bytes(), &locateupload_resp)
if err != nil {
log.Debugln(resp)
return err

View File

@ -13,8 +13,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
const (
@ -80,7 +80,7 @@ func (d *Terabox) request(rurl string, method string, callback base.ReqCallback,
if err != nil {
return nil, err
}
errno := utils.Json.Get(res.Body(), "errno").ToInt()
errno := utils.Json.Get(res.Bytes(), "errno").ToInt()
if errno == 4000023 {
// reget jsToken
err = d.resetJsToken()
@ -101,7 +101,7 @@ func (d *Terabox) request(rurl string, method string, callback base.ReqCallback,
return d.request(rurl, method, callback, resp, noRetry...)
}
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Terabox) get(pathname string, params map[string]string, resp interface{}) ([]byte, error) {

View File

@ -19,7 +19,7 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Thunder struct {

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
const (
@ -186,7 +186,7 @@ func (c *Common) Request(url, method string, callback base.ReqCallback, resp int
}
var erron ErrResp
utils.Json.Unmarshal(res.Body(), &erron)
utils.Json.Unmarshal(res.Bytes(), &erron)
if erron.IsError() {
// review_panel 表示需要短信验证码进行验证
if erron.ErrorMsg == "review_panel" {
@ -196,7 +196,7 @@ func (c *Common) Request(url, method string, callback base.ReqCallback, resp int
return nil, &erron
}
return res.Body(), nil
return res.Bytes(), nil
}
// 获取验证所需内容
@ -204,7 +204,7 @@ func (c *Common) getReviewData(res *resty.Response) error {
var reviewResp LoginReviewResp
var reviewData ReviewData
if err := utils.Json.Unmarshal(res.Body(), &reviewResp); err != nil {
if err := utils.Json.Unmarshal(res.Bytes(), &reviewResp); err != nil {
return err
}

View File

@ -20,7 +20,7 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type ThunderBrowser struct {

View File

@ -14,7 +14,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
const (
@ -227,7 +227,7 @@ func (c *Common) Request(url, method string, callback base.ReqCallback, resp int
}
var erron ErrResp
utils.Json.Unmarshal(res.Body(), &erron)
utils.Json.Unmarshal(res.Bytes(), &erron)
if erron.IsError() {
// review_panel 表示需要短信验证码进行验证
if erron.ErrorMsg == "review_panel" {
@ -237,7 +237,7 @@ func (c *Common) Request(url, method string, callback base.ReqCallback, resp int
return nil, &erron
}
return res.Body(), nil
return res.Bytes(), nil
}
// 获取验证所需内容
@ -245,7 +245,7 @@ func (c *Common) getReviewData(res *resty.Response) error {
var reviewResp LoginReviewResp
var reviewData ReviewData
if err := utils.Json.Unmarshal(res.Body(), &reviewResp); err != nil {
if err := utils.Json.Unmarshal(res.Bytes(), &reviewResp); err != nil {
return err
}

View File

@ -18,7 +18,7 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type ThunderX struct {

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
const (
@ -208,12 +208,12 @@ func (c *Common) Request(url, method string, callback base.ReqCallback, resp int
}
var erron ErrResp
utils.Json.Unmarshal(res.Body(), &erron)
utils.Json.Unmarshal(res.Bytes(), &erron)
if erron.IsError() {
return nil, &erron
}
return res.Body(), nil
return res.Bytes(), nil
}
// 计算文件Gcid

View File

@ -9,8 +9,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"github.com/OpenListTeam/wopan-sdk-go"
"resty.dev/v3"
)
type Wopan struct {
@ -152,10 +152,14 @@ func (d *Wopan) Remove(ctx context.Context, obj model.Obj) error {
}
func (d *Wopan) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
_, err := d.client.Upload2C(d.getSpaceType(), wopan.Upload2CFile{
file, err := stream.CacheFullInTempFile()
if err != nil {
return err
}
_, err = d.client.Upload2C(d.getSpaceType(), wopan.Upload2CFile{
Name: stream.GetName(),
Size: stream.GetSize(),
Content: driver.NewLimitedUploadStream(ctx, stream),
Content: driver.NewLimitedUploadFile(ctx, file),
ContentType: stream.GetMimetype(),
}, dstDir.GetID(), d.FamilyID, wopan.Upload2COption{
OnProgress: func(current, total int64) {

View File

@ -10,7 +10,7 @@ type Object struct {
FID string
}
func fileToObj(file wopan.File) (model.Obj, error) {
func fileToObj(file *wopan.File) (model.Obj, error) {
t, err := getTime(file.CreateTime)
if err != nil {
return nil, err

View File

@ -10,7 +10,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type YandexDisk struct {

View File

@ -8,7 +8,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -97,7 +97,7 @@ func (d *YandexDisk) request(pathname string, method string, callback base.ReqCa
}
return nil, errors.New(e.Description)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *YandexDisk) getFiles(path string) ([]File, error) {

6
go.mod
View File

@ -10,7 +10,7 @@ require (
github.com/OpenListTeam/sftpd-openlist v1.0.1
github.com/OpenListTeam/tache v0.2.0
github.com/OpenListTeam/times v0.1.0
github.com/OpenListTeam/wopan-sdk-go v0.1.5
github.com/OpenListTeam/wopan-sdk-go v0.2.2
github.com/ProtonMail/go-crypto v1.0.0
github.com/SheltonZhu/115driver v1.0.34
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
@ -33,7 +33,6 @@ require (
github.com/foxxorcat/weiyun-sdk-go v0.1.3
github.com/gin-contrib/cors v1.7.2
github.com/gin-gonic/gin v1.10.0
github.com/go-resty/resty/v2 v2.14.0
github.com/go-webauthn/webauthn v0.11.1
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.6.0
@ -81,6 +80,7 @@ require (
require (
cloud.google.com/go/compute/metadata v0.7.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/go-resty/resty/v2 v2.14.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/mikelolasagasti/xz v1.0.1 // indirect
github.com/minio/minlz v1.0.0 // indirect
@ -120,7 +120,7 @@ require (
github.com/ulikunitz/xz v0.5.12 // indirect
github.com/yuin/goldmark v1.7.8
go4.org v0.0.0-20230225012048-214862532bf5
resty.dev/v3 v3.0.0-beta.2 // indirect
resty.dev/v3 v3.0.0-beta.3
)
require (

8
go.sum
View File

@ -48,8 +48,8 @@ github.com/OpenListTeam/tache v0.2.0 h1:Q4MjuyECn0CZCf1ZF91JaVaZTaps1mOTAm8bFj8s
github.com/OpenListTeam/tache v0.2.0/go.mod h1:qmnZ/VpY2DUlmjg3UoDeNFy/LRqrw0biN3hYEEGc/+A=
github.com/OpenListTeam/times v0.1.0 h1:qknxw+qj5CYKgXAwydA102UEpPcpU8TYNGRmwRyPYpg=
github.com/OpenListTeam/times v0.1.0/go.mod h1:Jx7qen5NCYzKk2w14YuvU48YYMcPa1P9a+EJePC15Pc=
github.com/OpenListTeam/wopan-sdk-go v0.1.5 h1:iKKcVzIqBgtGDbn0QbdWrCazSGxXFmYFyrnFBG+U8dI=
github.com/OpenListTeam/wopan-sdk-go v0.1.5/go.mod h1:otynv0CgSNUClPpUgZ44qCZGcMRe0dc83Pkk65xAunI=
github.com/OpenListTeam/wopan-sdk-go v0.2.2 h1:B91gBp4P/KwVxTAwZ8gYr+QrC6S/G/9OD9aNtFulEG0=
github.com/OpenListTeam/wopan-sdk-go v0.2.2/go.mod h1:AkF/ynk4lbOnMeAyEEJK7R0Ryz3NBMPZCMOepjeYwSw=
github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78=
github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/RoaringBitmap/roaring v1.9.3 h1:t4EbC5qQwnisr5PrP9nt0IRhRTb9gMUgQF4t4S2OByM=
@ -985,8 +985,8 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0=
lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
resty.dev/v3 v3.0.0-beta.2 h1:xu4mGAdbCLuc3kbk7eddWfWm4JfhwDtdapwss5nCjnQ=
resty.dev/v3 v3.0.0-beta.2/go.mod h1:OgkqiPvTDtOuV4MGZuUDhwOpkY8enjOsjjMzeOHefy4=
resty.dev/v3 v3.0.0-beta.3 h1:3kEwzEgCnnS6Ob4Emlk94t+I/gClyoah7SnNi67lt+E=
resty.dev/v3 v3.0.0-beta.3/go.mod h1:OgkqiPvTDtOuV4MGZuUDhwOpkY8enjOsjjMzeOHefy4=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=

View File

@ -53,7 +53,7 @@ func updateIgnorePaths(customIgnorePaths string) {
res, err := base.RestyClient.R().Get(url)
if err == nil {
log.Debugf("allow_indexed body: %+v", res.String())
allowIndexed = utils.Json.Get(res.Body(), "data", conf.AllowIndexed).ToString() == "true"
allowIndexed = utils.Json.Get(res.Bytes(), "data", conf.AllowIndexed).ToString() == "true"
v3Visited[addition.Address] = allowIndexed
}
}

View File

@ -21,9 +21,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/server/common"
"github.com/coreos/go-oidc"
"github.com/gin-gonic/gin"
"github.com/go-resty/resty/v2"
"golang.org/x/oauth2"
"gorm.io/gorm"
"resty.dev/v3"
)
const stateLength = 16
@ -382,11 +382,11 @@ func SSOLoginCallback(c *gin.Context) {
return
}
if platform == "Dingtalk" {
accessToken := utils.Json.Get(resp.Body(), "accessToken").ToString()
accessToken := utils.Json.Get(resp.Bytes(), "accessToken").ToString()
resp, err = ssoClient.R().SetHeader("x-acs-dingtalk-access-token", accessToken).
Get(userUrl)
} else {
accessToken := utils.Json.Get(resp.Body(), "access_token").ToString()
accessToken := utils.Json.Get(resp.Bytes(), "access_token").ToString()
resp, err = ssoClient.R().SetHeader("Authorization", "Bearer "+accessToken).
Get(userUrl)
}
@ -394,7 +394,7 @@ func SSOLoginCallback(c *gin.Context) {
common.ErrorResp(c, err, 400)
return
}
userID := utils.Json.Get(resp.Body(), idField).ToString()
userID := utils.Json.Get(resp.Bytes(), idField).ToString()
if utils.SliceContains([]string{"", "0"}, userID) {
common.ErrorResp(c, errors.New("error occurred"), 400)
return
@ -415,7 +415,7 @@ func SSOLoginCallback(c *gin.Context) {
c.Data(200, "text/html; charset=utf-8", []byte(html))
return
}
username := utils.Json.Get(resp.Body(), usernameField).ToString()
username := utils.Json.Get(resp.Bytes(), usernameField).ToString()
user, err := db.GetUserBySSOID(userID)
if err != nil {
user, err = autoRegister(username, userID, err)