mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-19 20:26:26 +08:00
Compare commits
5 Commits
v4.0.9
...
deps/resty
Author | SHA1 | Date | |
---|---|---|---|
101f4a2434 | |||
4990af3c09 | |||
82619cc9b2 | |||
9b69d8e3c4 | |||
a73b345749 |
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/setting"
|
"github.com/OpenListTeam/OpenList/v4/internal/setting"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DelAdminCacheOnline() {
|
func DelAdminCacheOnline() {
|
||||||
@ -42,8 +42,8 @@ func DelUserCacheOnline(username string) {
|
|||||||
utils.Log.Warnf("[del_user_cache_online] failed: %+v", res.String())
|
utils.Log.Warnf("[del_user_cache_online] failed: %+v", res.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
code := utils.Json.Get(res.Body(), "code").ToInt()
|
code := utils.Json.Get(res.Bytes(), "code").ToInt()
|
||||||
msg := utils.Json.Get(res.Body(), "message").ToString()
|
msg := utils.Json.Get(res.Bytes(), "message").ToString()
|
||||||
if code != 200 {
|
if code != 200 {
|
||||||
utils.Log.Errorf("[del_user_cache_online] error: %s", msg)
|
utils.Log.Errorf("[del_user_cache_online] error: %s", msg)
|
||||||
return
|
return
|
||||||
|
@ -2,7 +2,7 @@ package _115
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
|
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
|
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
|
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
|
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
)
|
)
|
||||||
@ -93,7 +93,7 @@ func (d *Pan115) MakeDir(ctx context.Context, parentDir model.Obj, dirName strin
|
|||||||
req := d.client.NewRequest().
|
req := d.client.NewRequest().
|
||||||
SetFormData(form).
|
SetFormData(form).
|
||||||
SetResult(&result).
|
SetResult(&result).
|
||||||
ForceContentType("application/json;charset=UTF-8")
|
SetForceResponseContentType("application/json;charset=UTF-8")
|
||||||
|
|
||||||
resp, err := req.Post(driver115.ApiDirAdd)
|
resp, err := req.Post(driver115.ApiDirAdd)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/SheltonZhu/115driver/pkg/driver"
|
"github.com/j2rong4cn/115driver/pkg/driver"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ model.Obj = (*FileObj)(nil)
|
var _ model.Obj = (*FileObj)(nil)
|
||||||
|
@ -24,9 +24,9 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||||
|
|
||||||
cipher "github.com/SheltonZhu/115driver/pkg/crypto/ec115"
|
cipher "github.com/j2rong4cn/115driver/pkg/crypto/ec115"
|
||||||
crypto "github.com/SheltonZhu/115driver/pkg/crypto/m115"
|
crypto "github.com/j2rong4cn/115driver/pkg/crypto/m115"
|
||||||
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
|
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ func (d *Pan115) getNewFileByPickCode(pickCode string) (*FileObj, error) {
|
|||||||
result := driver115.GetFileInfoResponse{}
|
result := driver115.GetFileInfoResponse{}
|
||||||
req := d.client.NewRequest().
|
req := d.client.NewRequest().
|
||||||
SetQueryParam("pick_code", pickCode).
|
SetQueryParam("pick_code", pickCode).
|
||||||
ForceContentType("application/json;charset=UTF-8").
|
SetForceResponseContentType("application/json;charset=UTF-8").
|
||||||
SetResult(&result)
|
SetResult(&result)
|
||||||
resp, err := req.Get(driver115.ApiFileInfo)
|
resp, err := req.Get(driver115.ApiFileInfo)
|
||||||
if err := driver115.CheckErr(err, &result, resp); err != nil {
|
if err := driver115.CheckErr(err, &result, resp); err != nil {
|
||||||
@ -125,7 +125,7 @@ func (d *Pan115) DownloadWithUA(pickCode, ua string) (*driver115.DownloadInfo, e
|
|||||||
req.Header.Set("Cookie", d.Cookie)
|
req.Header.Set("Cookie", d.Cookie)
|
||||||
req.Header.Set("User-Agent", ua)
|
req.Header.Set("User-Agent", ua)
|
||||||
|
|
||||||
resp, err := d.client.Client.GetClient().Do(req)
|
resp, err := d.client.Client.Client().Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ func (d *Pan115) rapidUpload(fileSize int64, fileName, dirID, preID, fileID stri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
data := resp.RawBody()
|
data := resp.Body
|
||||||
defer data.Close()
|
defer data.Close()
|
||||||
if bodyBytes, err = io.ReadAll(data); err != nil {
|
if bodyBytes, err = io.ReadAll(data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
|
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
|
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Pan123 struct {
|
type Pan123 struct {
|
||||||
@ -115,7 +115,7 @@ func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
|
|||||||
if res.StatusCode() == 302 {
|
if res.StatusCode() == 302 {
|
||||||
link.URL = res.Header().Get("location")
|
link.URL = res.Header().Get("location")
|
||||||
} else if res.StatusCode() < 300 {
|
} 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{
|
link.Header = http.Header{
|
||||||
"Referer": []string{"https://www.123pan.com/"},
|
"Referer": []string{"https://www.123pan.com/"},
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"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) {
|
func (d *Pan123) getS3PreSignedUrls(ctx context.Context, upReq *UploadResp, start, end int) (*S3PreSignedURLs, error) {
|
||||||
|
@ -15,9 +15,9 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// do others that not defined in Driver interface
|
||||||
@ -172,10 +172,10 @@ func (d *Pan123) login() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if utils.Json.Get(res.Body(), "code").ToInt() != 200 {
|
if utils.Json.Get(res.Bytes(), "code").ToInt() != 200 {
|
||||||
err = fmt.Errorf(utils.Json.Get(res.Body(), "message").ToString())
|
err = fmt.Errorf(utils.Json.Get(res.Bytes(), "message").ToString())
|
||||||
} else {
|
} else {
|
||||||
d.AccessToken = utils.Json.Get(res.Body(), "data", "token").ToString()
|
d.AccessToken = utils.Json.Get(res.Bytes(), "data", "token").ToString()
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ do:
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
body := res.Body()
|
body := res.Bytes()
|
||||||
code := utils.Json.Get(body, "code").ToInt()
|
code := utils.Json.Get(body, "code").ToInt()
|
||||||
if code != 0 {
|
if code != 0 {
|
||||||
if !isRetry && code == 401 {
|
if !isRetry && code == 401 {
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
|
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/avast/retry-go"
|
"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) {
|
func (d *Open123) create(parentFileID int64, filename string, etag string, size int64, duplicate int, containDir bool) (*UploadCreateResp, error) {
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ( //不同情况下获取的AccessTokenQPS限制不同 如下模块化易于拓展
|
var ( //不同情况下获取的AccessTokenQPS限制不同 如下模块化易于拓展
|
||||||
@ -56,7 +56,7 @@ func (d *Open123) Request(apiInfo *ApiInfo, method string, callback base.ReqCall
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
body := res.Body()
|
body := res.Bytes()
|
||||||
|
|
||||||
// 解析为通用响应
|
// 解析为通用响应
|
||||||
var baseResp BaseResp
|
var baseResp BaseResp
|
||||||
|
@ -17,8 +17,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Pan123Share struct {
|
type Pan123Share struct {
|
||||||
@ -119,7 +119,7 @@ func (d *Pan123Share) Link(ctx context.Context, file model.Obj, args model.LinkA
|
|||||||
if res.StatusCode() == 302 {
|
if res.StatusCode() == 302 {
|
||||||
link.URL = res.Header().Get("location")
|
link.URL = res.Header().Get("location")
|
||||||
} else if res.StatusCode() < 300 {
|
} 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{
|
link.Header = http.Header{
|
||||||
"Referer": []string{"https://www.123pan.com/"},
|
"Referer": []string{"https://www.123pan.com/"},
|
||||||
|
@ -15,8 +15,8 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -76,7 +76,7 @@ func (d *Pan123Share) request(url string, method string, callback base.ReqCallba
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
body := res.Body()
|
body := res.Bytes()
|
||||||
code := utils.Json.Get(body, "code").ToInt()
|
code := utils.Json.Get(body, "code").ToInt()
|
||||||
if code != 0 {
|
if code != 0 {
|
||||||
return nil, errors.New(jsoniter.Get(body, "message").ToString())
|
return nil, errors.New(jsoniter.Get(body, "message").ToString())
|
||||||
|
@ -286,10 +286,8 @@ type PersonalUploadUrlResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type QueryRoutePolicyResp struct {
|
type QueryRoutePolicyResp struct {
|
||||||
Success bool `json:"success"`
|
BaseResp
|
||||||
Code string `json:"code"`
|
Data struct {
|
||||||
Message string `json:"message"`
|
|
||||||
Data struct {
|
|
||||||
RoutePolicyList []struct {
|
RoutePolicyList []struct {
|
||||||
SiteID string `json:"siteID"`
|
SiteID string `json:"siteID"`
|
||||||
SiteCode string `json:"siteCode"`
|
SiteCode string `json:"siteCode"`
|
||||||
|
@ -17,9 +17,9 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// do others that not defined in Driver interface
|
||||||
@ -89,7 +89,7 @@ func (d *Yun139) refreshToken() error {
|
|||||||
var resp RefreshTokenResp
|
var resp RefreshTokenResp
|
||||||
reqBody := "<root><token>" + splits[2] + "</token><account>" + splits[1] + "</account><clienttype>656</clienttype></root>"
|
reqBody := "<root><token>" + splits[2] + "</token><account>" + splits[1] + "</account><clienttype>656</clienttype></root>"
|
||||||
_, err = base.RestyClient.R().
|
_, err = base.RestyClient.R().
|
||||||
ForceContentType("application/xml").
|
SetForceResponseContentType("application/xml").
|
||||||
SetBody(reqBody).
|
SetBody(reqBody).
|
||||||
SetResult(&resp).
|
SetResult(&resp).
|
||||||
Post(url)
|
Post(url)
|
||||||
@ -150,29 +150,24 @@ func (d *Yun139) request(pathname string, method string, callback base.ReqCallba
|
|||||||
return nil, errors.New(e.Message)
|
return nil, errors.New(e.Message)
|
||||||
}
|
}
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
err = utils.Json.Unmarshal(res.Body(), resp)
|
err = utils.Json.Unmarshal(res.Bytes(), resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error) {
|
func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error) {
|
||||||
|
body, err := utils.Json.Marshal(data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
url := "https://user-njs.yun.139.com/user/route/qryRoutePolicy"
|
url := "https://user-njs.yun.139.com/user/route/qryRoutePolicy"
|
||||||
req := base.RestyClient.R()
|
req := base.RestyClient.R()
|
||||||
randStr := random.String(16)
|
randStr := random.String(16)
|
||||||
ts := time.Now().Format("2006-01-02 15:04:05")
|
ts := time.Now().Format("2006-01-02 15:04:05")
|
||||||
callback := func(req *resty.Request) {
|
req.SetBody(data)
|
||||||
req.SetBody(data)
|
|
||||||
}
|
|
||||||
if callback != nil {
|
|
||||||
callback(req)
|
|
||||||
}
|
|
||||||
body, err := utils.Json.Marshal(req.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
sign := calSign(string(body), ts, randStr)
|
sign := calSign(string(body), ts, randStr)
|
||||||
svcType := "1"
|
svcType := "1"
|
||||||
if d.isFamily() {
|
if d.isFamily() {
|
||||||
@ -199,20 +194,24 @@ func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error
|
|||||||
"Inner-Hcy-Router-Https": "1",
|
"Inner-Hcy-Router-Https": "1",
|
||||||
})
|
})
|
||||||
|
|
||||||
var e BaseResp
|
|
||||||
req.SetResult(&e)
|
|
||||||
res, err := req.Execute(http.MethodPost, url)
|
res, err := req.Execute(http.MethodPost, url)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
log.Debugln(res.String())
|
log.Debugln(res.String())
|
||||||
|
var e BaseResp
|
||||||
|
err = utils.Json.Unmarshal(res.Bytes(), &e)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if !e.Success {
|
if !e.Success {
|
||||||
return nil, errors.New(e.Message)
|
return nil, errors.New(e.Message)
|
||||||
}
|
}
|
||||||
if resp != nil {
|
err = utils.Json.Unmarshal(res.Bytes(), resp)
|
||||||
err = utils.Json.Unmarshal(res.Body(), resp)
|
if err != nil {
|
||||||
if err != nil {
|
return nil, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Yun139) post(pathname string, data interface{}, resp interface{}) ([]byte, error) {
|
func (d *Yun139) post(pathname string, data interface{}, resp interface{}) ([]byte, error) {
|
||||||
@ -500,12 +499,12 @@ func (d *Yun139) personalRequest(pathname string, method string, callback base.R
|
|||||||
return nil, errors.New(e.Message)
|
return nil, errors.New(e.Message)
|
||||||
}
|
}
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
err = utils.Json.Unmarshal(res.Body(), resp)
|
err = utils.Json.Unmarshal(res.Bytes(), resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
func (d *Yun139) personalPost(pathname string, data interface{}, resp interface{}) ([]byte, error) {
|
func (d *Yun139) personalPost(pathname string, data interface{}, resp interface{}) ([]byte, error) {
|
||||||
return d.personalRequest(pathname, http.MethodPost, func(req *resty.Request) {
|
return d.personalRequest(pathname, http.MethodPost, func(req *resty.Request) {
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Cloud189 struct {
|
type Cloud189 struct {
|
||||||
@ -52,7 +52,7 @@ func (d *Cloud189) Link(ctx context.Context, file model.Obj, args model.LinkArgs
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 {
|
resty.RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
|
||||||
return http.ErrUseLastResponse
|
return http.ErrUseLastResponse
|
||||||
}))
|
}))
|
||||||
|
@ -83,7 +83,7 @@ func (d *Cloud189) newLogin() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = utils.Json.Unmarshal(res.Body(), &encryptConf)
|
err = utils.Json.Unmarshal(res.Bytes(), &encryptConf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -118,9 +118,9 @@ func (d *Cloud189) newLogin() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Debugf("189 login resp body: %s", res.String())
|
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 {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
myrand "github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
|
myrand "github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// do others that not defined in Driver interface
|
||||||
@ -81,7 +81,7 @@ import (
|
|||||||
// // Enter the verification code manually
|
// // Enter the verification code manually
|
||||||
// //err = message.GetMessenger().WaitSend(message.Message{
|
// //err = message.GetMessenger().WaitSend(message.Message{
|
||||||
// // Type: "image",
|
// // Type: "image",
|
||||||
// // Content: "data:image/png;base64," + base64.StdEncoding.EncodeToString(imgRes.Body()),
|
// // Content: "data:image/png;base64," + base64.StdEncoding.EncodeToString(imgRes.Body),
|
||||||
// //}, 10)
|
// //}, 10)
|
||||||
// //if err != nil {
|
// //if err != nil {
|
||||||
// // return err
|
// // return err
|
||||||
@ -89,15 +89,15 @@ import (
|
|||||||
// //vCodeRS, err = message.GetMessenger().WaitReceive(30)
|
// //vCodeRS, err = message.GetMessenger().WaitReceive(30)
|
||||||
// // use ocr api
|
// // use ocr api
|
||||||
// vRes, err := base.RestyClient.R().SetMultipartField(
|
// 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))
|
// Post(setting.GetStr(conf.OcrApi))
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return err
|
// return err
|
||||||
// }
|
// }
|
||||||
// if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
|
// if jsoniter.Get(vRes.Bytes(), "status").ToInt() != 200 {
|
||||||
// return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
|
// 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)
|
// log.Debugln("code: ", vCodeRS)
|
||||||
// }
|
// }
|
||||||
// userRsa := RsaEncode([]byte(d.Username), jRsakey, true)
|
// userRsa := RsaEncode([]byte(d.Username), jRsakey, true)
|
||||||
@ -128,7 +128,7 @@ import (
|
|||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return err
|
// return err
|
||||||
// }
|
// }
|
||||||
// err = utils.Json.Unmarshal(res.Body(), &loginResp)
|
// err = utils.Json.Unmarshal(res.Bytes(), &loginResp)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// log.Error(err.Error())
|
// log.Error(err.Error())
|
||||||
// return err
|
// return err
|
||||||
@ -167,10 +167,10 @@ func (d *Cloud189) request(url string, method string, callback base.ReqCallback,
|
|||||||
return d.request(url, method, callback, resp)
|
return d.request(url, method, callback, resp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if jsoniter.Get(res.Body(), "res_code").ToInt() != 0 {
|
if jsoniter.Get(res.Bytes(), "res_code").ToInt() != 0 {
|
||||||
err = errors.New(jsoniter.Get(res.Body(), "res_message").ToString())
|
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) {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if utils.Json.Get(res.Body(), "MD5").ToString() != "" {
|
if utils.Json.Get(res.Bytes(), "MD5").ToString() != "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Debugf(res.String())
|
log.Debugf(res.String())
|
||||||
@ -297,7 +297,7 @@ func (d *Cloud189) uploadRequest(uri string, form map[string]string, resp interf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
data = res.Body()
|
data = res.Bytes()
|
||||||
if utils.Json.Get(data, "code").ToString() != "SUCCESS" {
|
if utils.Json.Get(data, "code").ToString() != "SUCCESS" {
|
||||||
return nil, errors.New(uri + "---" + jsoniter.Get(data, "msg").ToString())
|
return nil, errors.New(uri + "---" + jsoniter.Get(data, "msg").ToString())
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Cloud189TV struct {
|
type Cloud189TV struct {
|
||||||
@ -126,7 +126,7 @@ func (y *Cloud189TV) Link(ctx context.Context, file model.Obj, args model.LinkAr
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer res.RawBody().Close()
|
defer res.Body.Close()
|
||||||
if res.StatusCode() == 302 {
|
if res.StatusCode() == 302 {
|
||||||
downloadUrl.URL = res.Header().Get("location")
|
downloadUrl.URL = res.Header().Get("location")
|
||||||
}
|
}
|
||||||
|
@ -5,23 +5,24 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/skip2/go-qrcode"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/skip2/go-qrcode"
|
||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
|
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -96,7 +97,7 @@ func (y *Cloud189TV) request(url, method string, callback base.ReqCallback, para
|
|||||||
if erron.HasError() {
|
if erron.HasError() {
|
||||||
return nil, &erron
|
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) {
|
func (y *Cloud189TV) get(url string, callback base.ReqCallback, resp interface{}, isFamily ...bool) ([]byte, error) {
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Cloud189PC struct {
|
type Cloud189PC struct {
|
||||||
@ -171,7 +171,7 @@ func (y *Cloud189PC) Link(ctx context.Context, file model.Obj, args model.LinkAr
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer res.RawBody().Close()
|
defer res.Body.Close()
|
||||||
if res.StatusCode() == 302 {
|
if res.StatusCode() == 302 {
|
||||||
downloadUrl.URL = res.Header().Get("location")
|
downloadUrl.URL = res.Header().Get("location")
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,10 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
|
|
||||||
"github.com/avast/retry-go"
|
"github.com/avast/retry-go"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -129,7 +129,7 @@ func (y *Cloud189PC) request(url, method string, callback base.ReqCallback, para
|
|||||||
if erron.HasError() {
|
if erron.HasError() {
|
||||||
return nil, &erron
|
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) {
|
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
|
param := y.loginParam
|
||||||
var loginresp LoginResp
|
var loginresp LoginResp
|
||||||
_, err = y.client.R().
|
_, err = y.client.R().
|
||||||
ForceContentType("application/json;charset=UTF-8").SetResult(&loginresp).
|
SetForceResponseContentType("application/json;charset=UTF-8").SetResult(&loginresp).
|
||||||
SetHeaders(map[string]string{
|
SetHeaders(map[string]string{
|
||||||
"REQID": param.ReqId,
|
"REQID": param.ReqId,
|
||||||
"lt": param.Lt,
|
"lt": param.Lt,
|
||||||
@ -370,7 +370,7 @@ func (y *Cloud189PC) initLoginParam() error {
|
|||||||
// 获取rsa公钥
|
// 获取rsa公钥
|
||||||
var encryptConf EncryptConfResp
|
var encryptConf EncryptConfResp
|
||||||
_, err = y.client.R().
|
_, 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}).
|
SetFormData(map[string]string{"appId": APP_ID}).
|
||||||
Post(AUTH_URL + "/api/logbox/config/encryptConf.do")
|
Post(AUTH_URL + "/api/logbox/config/encryptConf.do")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -411,19 +411,19 @@ func (y *Cloud189PC) initLoginParam() error {
|
|||||||
if imgRes.Size() > 20 {
|
if imgRes.Size() > 20 {
|
||||||
if setting.GetStr(conf.OcrApi) != "" && !y.NoUseOcr {
|
if setting.GetStr(conf.OcrApi) != "" && !y.NoUseOcr {
|
||||||
vRes, err := base.RestyClient.R().
|
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))
|
Post(setting.GetStr(conf.OcrApi))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if jsoniter.Get(vRes.Body(), "status").ToInt() == 200 {
|
if jsoniter.Get(vRes.Bytes(), "status").ToInt() == 200 {
|
||||||
y.VCode = jsoniter.Get(vRes.Body(), "result").ToString()
|
y.VCode = jsoniter.Get(vRes.Bytes(), "result").ToString()
|
||||||
return nil
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/stream"
|
"github.com/OpenListTeam/OpenList/v4/internal/stream"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
|
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AliDrive struct {
|
type AliDrive struct {
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/dustinxie/ecc"
|
"github.com/dustinxie/ecc"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *AliDrive) createSession() error {
|
func (d *AliDrive) createSession() error {
|
||||||
@ -62,7 +62,7 @@ func (d *AliDrive) refreshToken() error {
|
|||||||
var resp base.TokenResp
|
var resp base.TokenResp
|
||||||
var e RespErr
|
var e RespErr
|
||||||
_, err := base.RestyClient.R().
|
_, err := base.RestyClient.R().
|
||||||
//ForceContentType("application/json").
|
//SetForceResponseContentType("application/json").
|
||||||
SetBody(base.Json{"refresh_token": d.RefreshToken, "grant_type": "refresh_token"}).
|
SetBody(base.Json{"refresh_token": d.RefreshToken, "grant_type": "refresh_token"}).
|
||||||
SetResult(&resp).
|
SetResult(&resp).
|
||||||
SetError(&e).
|
SetError(&e).
|
||||||
@ -134,7 +134,7 @@ func (d *AliDrive) request(url, method string, callback base.ReqCallback, resp i
|
|||||||
} else if res.IsError() {
|
} else if res.IsError() {
|
||||||
return nil, errors.New("bad status code " + res.Status()), e
|
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) {
|
func (d *AliDrive) getFiles(fileId string) ([]File, error) {
|
||||||
|
@ -14,8 +14,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/OpenListTeam/rateg"
|
"github.com/OpenListTeam/rateg"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AliyundriveOpen struct {
|
type AliyundriveOpen struct {
|
||||||
|
@ -18,8 +18,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
|
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/avast/retry-go"
|
"github.com/avast/retry-go"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func makePartInfos(size int) []base.Json {
|
func makePartInfos(size int) []base.Json {
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// do others that not defined in Driver interface
|
||||||
@ -56,7 +56,7 @@ func (d *AliyundriveOpen) _refreshToken() (string, string, error) {
|
|||||||
//var resp base.TokenResp
|
//var resp base.TokenResp
|
||||||
var e ErrResp
|
var e ErrResp
|
||||||
res, err := base.RestyClient.R().
|
res, err := base.RestyClient.R().
|
||||||
//ForceContentType("application/json").
|
//SetForceResponseContentType("application/json").
|
||||||
SetBody(base.Json{
|
SetBody(base.Json{
|
||||||
"client_id": d.ClientID,
|
"client_id": d.ClientID,
|
||||||
"client_secret": d.ClientSecret,
|
"client_secret": d.ClientSecret,
|
||||||
@ -73,7 +73,7 @@ func (d *AliyundriveOpen) _refreshToken() (string, string, error) {
|
|||||||
if e.Code != "" {
|
if e.Code != "" {
|
||||||
return "", "", fmt.Errorf("failed to refresh token: %s", e.Message)
|
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 == "" {
|
if refresh == "" {
|
||||||
return "", "", fmt.Errorf("failed to refresh token: refresh token is empty, resp: %s", res.String())
|
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 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) {
|
func (d *AliyundriveOpen) list(ctx context.Context, data base.Json) (*Files, error) {
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
|
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/OpenListTeam/rateg"
|
"github.com/OpenListTeam/rateg"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AliyundriveShare struct {
|
type AliyundriveShare struct {
|
||||||
|
@ -90,7 +90,7 @@ func (d *AliyundriveShare) request(url, method string, callback base.ReqCallback
|
|||||||
return nil, errors.New(e.Code + ": " + e.Message)
|
return nil, errors.New(e.Code + ": " + e.Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resp.Body(), nil
|
return resp.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *AliyundriveShare) getFiles(fileId string) ([]File, error) {
|
func (d *AliyundriveShare) getFiles(fileId string) ([]File, error) {
|
||||||
|
@ -355,8 +355,8 @@ func (d *BaiduNetdisk) uploadSlice(ctx context.Context, params map[string]string
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Debugln(res.RawResponse.Status + res.String())
|
log.Debugln(res.RawResponse.Status + res.String())
|
||||||
errCode := utils.Json.Get(res.Body(), "error_code").ToInt()
|
errCode := utils.Json.Get(res.Bytes(), "error_code").ToInt()
|
||||||
errNo := utils.Json.Get(res.Body(), "errno").ToInt()
|
errNo := utils.Json.Get(res.Bytes(), "errno").ToInt()
|
||||||
if errCode != 0 || errNo != 0 {
|
if errCode != 0 || errNo != 0 {
|
||||||
return errs.NewErr(errs.StreamIncomplete, "error in uploading to baidu, will retry. response=%s", res.String())
|
return errs.NewErr(errs.StreamIncomplete, "error in uploading to baidu, will retry. response=%s", res.String())
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/avast/retry-go"
|
"github.com/avast/retry-go"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
log.Debugf("[baidu_netdisk] req: %s, resp: %s", furl, res.String())
|
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 errno != 0 {
|
||||||
if utils.SliceContains([]int{111, -6}, errno) {
|
if utils.SliceContains([]int{111, -6}, errno) {
|
||||||
log.Info("refreshing baidu_netdisk token.")
|
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" {
|
if 31023 == errno && d.DownloadAPI == "crack_video" {
|
||||||
result = res.Body()
|
result = res.Bytes()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("req: [%s] ,errno: %d, refer to https://pan.baidu.com/union/doc/", furl, errno)
|
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
|
return nil
|
||||||
},
|
},
|
||||||
retry.LastErrorOnly(true),
|
retry.LastErrorOnly(true),
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/pkg/errgroup"
|
"github.com/OpenListTeam/OpenList/v4/pkg/errgroup"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/avast/retry-go"
|
"github.com/avast/retry-go"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BaiduPhoto struct {
|
type BaiduPhoto struct {
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -38,7 +38,7 @@ func (d *BaiduPhoto) Request(client *resty.Client, furl string, method string, c
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
erron := utils.Json.Get(res.Body(), "errno").ToInt()
|
erron := utils.Json.Get(res.Bytes(), "errno").ToInt()
|
||||||
switch erron {
|
switch erron {
|
||||||
case 0:
|
case 0:
|
||||||
break
|
break
|
||||||
@ -63,7 +63,7 @@ func (d *BaiduPhoto) Request(client *resty.Client, furl string, method string, c
|
|||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
// }
|
// }
|
||||||
// return res.Body(), nil
|
// return res.Bytes(), nil
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// func (d *BaiduPhoto) refreshToken() error {
|
// func (d *BaiduPhoto) refreshToken() error {
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/conf"
|
"github.com/OpenListTeam/OpenList/v4/internal/conf"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/net"
|
"github.com/OpenListTeam/OpenList/v4/internal/net"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -34,7 +34,6 @@ func NewRestyClient() *resty.Client {
|
|||||||
client := resty.New().
|
client := resty.New().
|
||||||
SetHeader("user-agent", UserAgent).
|
SetHeader("user-agent", UserAgent).
|
||||||
SetRetryCount(3).
|
SetRetryCount(3).
|
||||||
SetRetryResetReaders(true).
|
|
||||||
SetTimeout(DefaultTimeout).
|
SetTimeout(DefaultTimeout).
|
||||||
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify})
|
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify})
|
||||||
return client
|
return client
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package base
|
package base
|
||||||
|
|
||||||
import "github.com/go-resty/resty/v2"
|
import "resty.dev/v3"
|
||||||
|
|
||||||
type Json map[string]interface{}
|
type Json map[string]interface{}
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
|
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"google.golang.org/appengine/log"
|
"google.golang.org/appengine/log"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ChaoXing struct {
|
type ChaoXing struct {
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ChaoXing) GetFiles(parent string) ([]File, error) {
|
func (d *ChaoXing) GetFiles(parent string) ([]File, error) {
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Cloudreve struct {
|
type Cloudreve struct {
|
||||||
|
@ -20,8 +20,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/setting"
|
"github.com/OpenListTeam/OpenList/v4/internal/setting"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/cookie"
|
"github.com/OpenListTeam/OpenList/v4/pkg/cookie"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// do others that not defined in Driver interface
|
||||||
@ -134,10 +134,10 @@ func (d *Cloudreve) doLogin(needCaptcha bool) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
|
if jsoniter.Get(vRes.Bytes(), "status").ToInt() != 200 {
|
||||||
return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
|
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
|
var resp Resp
|
||||||
err = d.request(http.MethodPost, loginPath, func(req *resty.Request) {
|
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("Content-Length", strconv.FormatInt(byteSize, 10))
|
||||||
req.SetHeader("User-Agent", d.getUA())
|
req.SetHeader("User-Agent", d.getUA())
|
||||||
req.SetBody(driver.NewLimitedUploadStream(ctx, bytes.NewReader(byteData)))
|
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 {
|
if err != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -214,7 +214,7 @@ func (d *Cloudreve) upLocal(ctx context.Context, stream model.FileStreamer, u Up
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
var retryResp Resp
|
var retryResp Resp
|
||||||
jErr := base.RestyClient.JSONUnmarshal(r.Body(), &retryResp)
|
jErr := utils.Json.Unmarshal(r.Bytes(), &retryResp)
|
||||||
if jErr != nil {
|
if jErr != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CloudreveV4 struct {
|
type CloudreveV4 struct {
|
||||||
|
@ -20,8 +20,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/setting"
|
"github.com/OpenListTeam/OpenList/v4/internal/setting"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// do others that not defined in Driver interface
|
||||||
@ -153,10 +153,10 @@ func (d *CloudreveV4) doLogin(needCaptcha bool) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
|
if jsoniter.Get(vRes.Bytes(), "status").ToInt() != 200 {
|
||||||
return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
|
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 == "" {
|
if captchaCode == "" {
|
||||||
return errors.New("ocr error: empty result")
|
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.SetContentLength(true)
|
||||||
req.SetHeader("Content-Length", strconv.FormatInt(byteSize, 10))
|
req.SetHeader("Content-Length", strconv.FormatInt(byteSize, 10))
|
||||||
req.SetBody(driver.NewLimitedUploadStream(ctx, bytes.NewReader(byteData)))
|
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 {
|
if err != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -232,7 +232,7 @@ func (d *CloudreveV4) upLocal(ctx context.Context, file model.FileStreamer, u Fi
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
var retryResp Resp
|
var retryResp Resp
|
||||||
jErr := base.RestyClient.JSONUnmarshal(r.Body(), &retryResp)
|
jErr := utils.Json.Unmarshal(r.Bytes(), &retryResp)
|
||||||
if jErr != nil {
|
if jErr != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Doubao struct {
|
type Doubao struct {
|
||||||
|
@ -27,9 +27,9 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/pkg/errgroup"
|
"github.com/OpenListTeam/OpenList/v4/pkg/errgroup"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/avast/retry-go"
|
"github.com/avast/retry-go"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -83,7 +83,7 @@ func (d *Doubao) request(path string, method string, callback base.ReqCallback,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
body := res.Body()
|
body := res.Bytes()
|
||||||
// 先解析为通用响应
|
// 先解析为通用响应
|
||||||
if err = json.Unmarshal(body, &commonResp); err != nil {
|
if err = json.Unmarshal(body, &commonResp); err != nil {
|
||||||
return nil, err
|
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)
|
canonicalHeaders, signedHeaders := getCanonicalHeadersFromMap(req.Header)
|
||||||
canonicalRequest := method + "\n" +
|
canonicalRequest := method + "\n" +
|
||||||
@ -270,7 +270,7 @@ func (d *Doubao) requestApi(url, method, tokenType string, callback base.ReqCall
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Doubao) initUploadToken() (*UploadToken, error) {
|
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 nil, fmt.Errorf("upload request failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化分片上传
|
// 初始化分片上传
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DoubaoShare struct {
|
type DoubaoShare struct {
|
||||||
|
@ -12,8 +12,8 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -72,7 +72,7 @@ func (d *DoubaoShare) request(path string, method string, callback base.ReqCallb
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
body := res.Body()
|
body := res.Bytes()
|
||||||
// 先解析为通用响应
|
// 先解析为通用响应
|
||||||
if err = json.Unmarshal(body, &commonResp); err != nil {
|
if err = json.Unmarshal(body, &commonResp); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -12,8 +12,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Dropbox struct {
|
type Dropbox struct {
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *Dropbox) refreshToken() error {
|
func (d *Dropbox) refreshToken() error {
|
||||||
@ -49,7 +49,7 @@ func (d *Dropbox) refreshToken() error {
|
|||||||
url := d.base + "/oauth2/token"
|
url := d.base + "/oauth2/token"
|
||||||
var tokenResp TokenResp
|
var tokenResp TokenResp
|
||||||
resp, err := base.RestyClient.R().
|
resp, err := base.RestyClient.R().
|
||||||
//ForceContentType("application/x-www-form-urlencoded").
|
//SetForceResponseContentType("application/x-www-form-urlencoded").
|
||||||
//SetBasicAuth(d.ClientID, d.ClientSecret).
|
//SetBasicAuth(d.ClientID, d.ClientSecret).
|
||||||
SetFormData(map[string]string{
|
SetFormData(map[string]string{
|
||||||
"grant_type": "refresh_token",
|
"grant_type": "refresh_token",
|
||||||
@ -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 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) {
|
func (d *Dropbox) list(ctx context.Context, data base.Json, isContinue bool) (*ListResp, error) {
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *FebBox) refreshTokenByOAuth2() error {
|
func (d *FebBox) refreshTokenByOAuth2() error {
|
||||||
@ -48,9 +48,9 @@ func (d *FebBox) request(url string, method string, callback base.ReqCallback, r
|
|||||||
|
|
||||||
switch e.ErrorCode {
|
switch e.ErrorCode {
|
||||||
case 0:
|
case 0:
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
case 1:
|
case 1:
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
case -10001:
|
case -10001:
|
||||||
if e.ServerName != "" {
|
if e.ServerName != "" {
|
||||||
// access_token 过期
|
// access_token 过期
|
||||||
|
@ -17,9 +17,9 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/ProtonMail/go-crypto/openpgp"
|
"github.com/ProtonMail/go-crypto/openpgp"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Github struct {
|
type Github struct {
|
||||||
@ -680,7 +680,7 @@ func (d *Github) get(path string) (*Object, error) {
|
|||||||
return nil, toErr(res)
|
return nil, toErr(res)
|
||||||
}
|
}
|
||||||
var resp Object
|
var resp Object
|
||||||
err = utils.Json.Unmarshal(res.Body(), &resp)
|
err = utils.Json.Unmarshal(res.Bytes(), &resp)
|
||||||
return &resp, err
|
return &resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ func (d *Github) getTree(sha string) (*TreeResp, error) {
|
|||||||
return nil, toErr(res)
|
return nil, toErr(res)
|
||||||
}
|
}
|
||||||
var resp TreeResp
|
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 nil, err
|
||||||
}
|
}
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
@ -818,7 +818,7 @@ func (d *Github) newTree(baseSha string, tree []interface{}) (string, error) {
|
|||||||
return "", toErr(res)
|
return "", toErr(res)
|
||||||
}
|
}
|
||||||
var resp TreeResp
|
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 "", err
|
||||||
}
|
}
|
||||||
return resp.Sha, nil
|
return resp.Sha, nil
|
||||||
@ -847,7 +847,7 @@ func (d *Github) commit(message, treeSha string) error {
|
|||||||
return toErr(res)
|
return toErr(res)
|
||||||
}
|
}
|
||||||
var resp CommitResp
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -876,7 +876,7 @@ func (d *Github) getBranchHead() (string, error) {
|
|||||||
return "", toErr(res)
|
return "", toErr(res)
|
||||||
}
|
}
|
||||||
var resp BranchResp
|
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 "", err
|
||||||
}
|
}
|
||||||
return resp.Commit.Sha, nil
|
return resp.Commit.Sha, nil
|
||||||
@ -936,7 +936,7 @@ func (d *Github) getRepo() (*RepoResp, error) {
|
|||||||
return nil, toErr(res)
|
return nil, toErr(res)
|
||||||
}
|
}
|
||||||
var resp RepoResp
|
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 nil, err
|
||||||
}
|
}
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
@ -951,7 +951,7 @@ func (d *Github) getAuthenticatedUser() (*UserResp, error) {
|
|||||||
return nil, toErr(res)
|
return nil, toErr(res)
|
||||||
}
|
}
|
||||||
resp := &UserResp{}
|
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 nil, err
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/ProtonMail/go-crypto/openpgp"
|
"github.com/ProtonMail/go-crypto/openpgp"
|
||||||
"github.com/ProtonMail/go-crypto/openpgp/armor"
|
"github.com/ProtonMail/go-crypto/openpgp/armor"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MessageTemplateVars struct {
|
type MessageTemplateVars struct {
|
||||||
@ -40,7 +40,7 @@ func calculateBase64Length(inputLength int64) int64 {
|
|||||||
|
|
||||||
func toErr(res *resty.Response) error {
|
func toErr(res *resty.Response) error {
|
||||||
var errMsg ErrResp
|
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())
|
return errors.New(res.Status())
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("%s: %s", res.Status(), errMsg.Message)
|
return fmt.Errorf("%s: %s", res.Status(), errMsg.Message)
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MountPoint struct {
|
type MountPoint struct {
|
||||||
@ -26,7 +26,7 @@ func (m *MountPoint) RequestRelease(get func(url string) (*resty.Response, error
|
|||||||
if m.Release == nil || refresh {
|
if m.Release == nil || refresh {
|
||||||
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/releases/latest")
|
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/releases/latest")
|
||||||
m.Release = new(Release)
|
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 {
|
if m.Releases == nil || refresh {
|
||||||
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/releases")
|
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/releases")
|
||||||
m.Releases = new([]Release)
|
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 {
|
if m.OtherFile == nil || refresh {
|
||||||
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/contents")
|
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/contents")
|
||||||
m.OtherFile = new([]FileInfo)
|
m.OtherFile = new([]FileInfo)
|
||||||
json.Unmarshal(resp.Body(), m.OtherFile)
|
json.Unmarshal(resp.Bytes(), m.OtherFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
files := make([]File, 0)
|
files := make([]File, 0)
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 发送 GET 请求
|
// 发送 GET 请求
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GoogleDrive struct {
|
type GoogleDrive struct {
|
||||||
|
@ -17,9 +17,9 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
|
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"github.com/golang-jwt/jwt/v4"
|
"github.com/golang-jwt/jwt/v4"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// 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 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) {
|
func (d *GoogleDrive) getFiles(id string) ([]File, error) {
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GooglePhoto struct {
|
type GooglePhoto struct {
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// 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 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) {
|
func (d *GooglePhoto) getFiles(id string) ([]MediaItem, error) {
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/stream"
|
"github.com/OpenListTeam/OpenList/v4/internal/stream"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/foxxorcat/mopan-sdk-go"
|
"github.com/foxxorcat/mopan-sdk-go"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ILanZou struct {
|
type ILanZou struct {
|
||||||
@ -166,7 +166,7 @@ func (d *ILanZou) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
|
|||||||
if res.StatusCode() == 302 {
|
if res.StatusCode() == 302 {
|
||||||
realURL = res.Header().Get("location")
|
realURL = res.Header().Get("location")
|
||||||
} else {
|
} 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}
|
link := model.Link{URL: realURL}
|
||||||
return &link, nil
|
return &link, nil
|
||||||
@ -316,14 +316,14 @@ func (d *ILanZou) Put(ctx context.Context, dstDir model.Obj, s model.FileStreame
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
token = utils.Json.Get(res.Body(), "token").ToString()
|
token = utils.Json.Get(res.Bytes(), "token").ToString()
|
||||||
} else {
|
} else {
|
||||||
keyBase64 := base64.URLEncoding.EncodeToString([]byte(key))
|
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))
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uploadId := utils.Json.Get(res.Body(), "uploadId").ToString()
|
uploadId := utils.Json.Get(res.Bytes(), "uploadId").ToString()
|
||||||
parts := make([]Part, 0)
|
parts := make([]Part, 0)
|
||||||
partNum := (s.GetSize() + DefaultPartSize - 1) / DefaultPartSize
|
partNum := (s.GetSize() + DefaultPartSize - 1) / DefaultPartSize
|
||||||
for i := 1; i <= int(partNum); i++ {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
etag := utils.Json.Get(res.Body(), "etag").ToString()
|
etag := utils.Json.Get(res.Bytes(), "etag").ToString()
|
||||||
parts = append(parts, Part{
|
parts = append(parts, Part{
|
||||||
PartNumber: i,
|
PartNumber: i,
|
||||||
ETag: etag,
|
ETag: etag,
|
||||||
@ -345,7 +345,7 @@ func (d *ILanZou) Put(ctx context.Context, dstDir model.Obj, s model.FileStreame
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
token = utils.Json.Get(res.Body(), "token").ToString()
|
token = utils.Json.Get(res.Bytes(), "token").ToString()
|
||||||
}
|
}
|
||||||
// commit upload
|
// commit upload
|
||||||
var resp UploadResultResp
|
var resp UploadResultResp
|
||||||
|
@ -12,8 +12,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/foxxorcat/mopan-sdk-go"
|
"github.com/foxxorcat/mopan-sdk-go"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *ILanZou) login() error {
|
func (d *ILanZou) login() error {
|
||||||
@ -92,7 +92,7 @@ func (d *ILanZou) request(pathname, method string, callback base.ReqCallback, pr
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
isRetry := len(retry) > 0 && retry[0]
|
isRetry := len(retry) > 0 && retry[0]
|
||||||
body := res.Body()
|
body := res.Bytes()
|
||||||
code := utils.Json.Get(body, "code").ToInt()
|
code := utils.Json.Get(body, "code").ToInt()
|
||||||
msg := utils.Json.Get(body, "msg").ToString()
|
msg := utils.Json.Get(body, "msg").ToString()
|
||||||
if code != 200 {
|
if code != 200 {
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type KodBox struct {
|
type KodBox struct {
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *KodBox) getToken() error {
|
func (d *KodBox) getToken() error {
|
||||||
@ -62,7 +62,7 @@ func (d *KodBox) request(method string, pathname string, callback base.ReqCallba
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err := utils.Json.Unmarshal(res.Body(), &commonResp)
|
err := utils.Json.Unmarshal(res.Bytes(), &commonResp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -83,5 +83,5 @@ func (d *KodBox) request(method string, pathname string, callback base.ReqCallba
|
|||||||
if commonResp.Code.(bool) == false {
|
if commonResp.Code.(bool) == false {
|
||||||
return nil, fmt.Errorf("request failed: %s", commonResp.Data)
|
return nil, fmt.Errorf("request failed: %s", commonResp.Data)
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LanZou struct {
|
type LanZou struct {
|
||||||
|
@ -16,8 +16,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var upClient *resty.Client
|
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) {
|
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) {
|
data, err := d.request(url, http.MethodPost, func(req *resty.Request) {
|
||||||
req.AddRetryCondition(func(r *resty.Response, err error) bool {
|
req.AddRetryConditions(func(r *resty.Response, err error) bool {
|
||||||
if utils.Json.Get(r.Body(), "zt").ToInt() == 4 {
|
if utils.Json.Get(r.Bytes(), "zt").ToInt() == 4 {
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ func (d *LanZou) request(url string, method string, callback base.ReqCallback, u
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Debugf("lanzou request: url=>%s ,stats=>%d ,body => %s\n", res.Request.URL, res.StatusCode(), res.String())
|
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) {
|
func (d *LanZou) Login() ([]*http.Cookie, error) {
|
||||||
@ -141,8 +141,8 @@ func (d *LanZou) Login() ([]*http.Cookie, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if utils.Json.Get(resp.Body(), "zt").ToInt() != 1 {
|
if utils.Json.Get(resp.Bytes(), "zt").ToInt() != 1 {
|
||||||
return nil, fmt.Errorf("login err: %s", resp.Body())
|
return nil, fmt.Errorf("login err: %s", resp.Bytes())
|
||||||
}
|
}
|
||||||
d.Cookie = CookieToString(resp.Cookies())
|
d.Cookie = CookieToString(resp.Cookies())
|
||||||
return resp.Cookies(), nil
|
return resp.Cookies(), nil
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
|
@ -27,7 +27,7 @@ func (d *LenovoNasShare) request(url string, method string, callback base.ReqCal
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
body := res.Body()
|
body := res.Bytes()
|
||||||
result := utils.Json.Get(body, "result").ToBool()
|
result := utils.Json.Get(body, "result").ToBool()
|
||||||
if !result {
|
if !result {
|
||||||
return nil, errors.New(jsoniter.Get(body, "error", "msg").ToString())
|
return nil, errors.New(jsoniter.Get(body, "error", "msg").ToString())
|
||||||
|
@ -18,9 +18,9 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MediaTrack struct {
|
type MediaTrack struct {
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// 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)
|
return nil, errors.New(e.Message)
|
||||||
}
|
}
|
||||||
if resp != nil {
|
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) {
|
func (d *MediaTrack) getFiles(parentId string) ([]File, error) {
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
|
@ -143,9 +143,7 @@ func (d *MoPan) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer res.Body.Close()
|
||||||
_ = res.RawBody().Close()
|
|
||||||
}()
|
|
||||||
if res.StatusCode() == 302 {
|
if res.StatusCode() == 302 {
|
||||||
data.DownloadUrl = res.Header().Get("location")
|
data.DownloadUrl = res.Header().Get("location")
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ func (d *NeteaseMusic) request(url, method string, opt ReqOption) ([]byte, error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if method == http.MethodGet {
|
if method == http.MethodGet {
|
||||||
@ -87,7 +87,7 @@ func (d *NeteaseMusic) request(url, method string, opt ReqOption) ([]byte, error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errs.NotImplement
|
return nil, errs.NotImplement
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Onedrive struct {
|
type Onedrive struct {
|
||||||
|
@ -16,8 +16,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var onedriveHostMap = map[string]Host{
|
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 nil, errors.New(e.Error.Message)
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Onedrive) getFiles(path string) ([]File, error) {
|
func (d *Onedrive) getFiles(path string) ([]File, error) {
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OnedriveAPP struct {
|
type OnedriveAPP struct {
|
||||||
|
@ -16,8 +16,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var onedriveHostMap = map[string]Host{
|
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 nil, errors.New(e.Error.Message)
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *OnedriveAPP) getFiles(path string) ([]File, error) {
|
func (d *OnedriveAPP) getFiles(path string) ([]File, error) {
|
||||||
|
@ -16,8 +16,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/OpenListTeam/OpenList/v4/server/common"
|
"github.com/OpenListTeam/OpenList/v4/server/common"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OpenList struct {
|
type OpenList struct {
|
||||||
@ -62,7 +62,7 @@ func (d *OpenList) Init(ctx context.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
if !allowMounted {
|
||||||
return fmt.Errorf("the site does not allow mounted")
|
return fmt.Errorf("the site does not allow mounted")
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/OpenListTeam/OpenList/v4/server/common"
|
"github.com/OpenListTeam/OpenList/v4/server/common"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *OpenList) login() error {
|
func (d *OpenList) login() error {
|
||||||
@ -50,7 +50,7 @@ func (d *OpenList) request(api, method string, callback base.ReqCallback, retry
|
|||||||
if res.StatusCode() >= 400 {
|
if res.StatusCode() >= 400 {
|
||||||
return nil, res.StatusCode(), fmt.Errorf("request failed, status: %s", res.Status())
|
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 != 200 {
|
||||||
if (code == 401 || code == 403) && !utils.IsBool(retry...) {
|
if (code == 401 || code == 403) && !utils.IsBool(retry...) {
|
||||||
err = d.login()
|
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 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
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
hash_extend "github.com/OpenListTeam/OpenList/v4/pkg/utils/hash"
|
hash_extend "github.com/OpenListTeam/OpenList/v4/pkg/utils/hash"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PikPak struct {
|
type PikPak struct {
|
||||||
|
@ -22,9 +22,9 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var AndroidAlgorithms = []string{
|
var AndroidAlgorithms = []string{
|
||||||
@ -121,7 +121,7 @@ func (d *PikPak) login() error {
|
|||||||
if e.ErrorCode != 0 {
|
if e.ErrorCode != 0 {
|
||||||
return &e
|
return &e
|
||||||
}
|
}
|
||||||
data := res.Body()
|
data := res.Bytes()
|
||||||
d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
|
d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
|
||||||
d.AccessToken = jsoniter.Get(data, "access_token").ToString()
|
d.AccessToken = jsoniter.Get(data, "access_token").ToString()
|
||||||
d.Common.SetUserID(jsoniter.Get(data, "sub").ToString())
|
d.Common.SetUserID(jsoniter.Get(data, "sub").ToString())
|
||||||
@ -157,7 +157,7 @@ func (d *PikPak) refreshToken(refreshToken string) error {
|
|||||||
op.MustSaveDriverStorage(d)
|
op.MustSaveDriverStorage(d)
|
||||||
return errors.New(e.Error())
|
return errors.New(e.Error())
|
||||||
}
|
}
|
||||||
data := res.Body()
|
data := res.Bytes()
|
||||||
d.Status = "work"
|
d.Status = "work"
|
||||||
d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
|
d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
|
||||||
d.AccessToken = jsoniter.Get(data, "access_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 {
|
switch e.ErrorCode {
|
||||||
case 0:
|
case 0:
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
case 4122, 4121, 16:
|
case 4122, 4121, 16:
|
||||||
// access_token 过期
|
// access_token 过期
|
||||||
if err1 := d.refreshToken(d.RefreshToken); err1 != nil {
|
if err1 := d.refreshToken(d.RefreshToken); err1 != nil {
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PikPakShare struct {
|
type PikPakShare struct {
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var AndroidAlgorithms = []string{
|
var AndroidAlgorithms = []string{
|
||||||
@ -100,7 +100,7 @@ func (d *PikPakShare) request(url string, method string, callback base.ReqCallba
|
|||||||
}
|
}
|
||||||
switch e.ErrorCode {
|
switch e.ErrorCode {
|
||||||
case 0:
|
case 0:
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
case 9: // 验证码token过期
|
case 9: // 验证码token过期
|
||||||
if err = d.RefreshCaptchaToken(GetAction(method, url), ""); err != nil {
|
if err = d.RefreshCaptchaToken(GetAction(method, url), ""); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -6,16 +6,17 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"hash"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
|
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
"hash"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type QuarkOpen struct {
|
type QuarkOpen struct {
|
||||||
|
@ -8,19 +8,20 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"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/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
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) {
|
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 nil, errors.New(e.ErrorInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *QuarkOpen) GetFiles(ctx context.Context, parent string) ([]File, error) {
|
func (d *QuarkOpen) GetFiles(ctx context.Context, parent string) ([]File, error) {
|
||||||
|
@ -15,8 +15,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
|
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type QuarkOrUC struct {
|
type QuarkOrUC struct {
|
||||||
|
@ -17,8 +17,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/cookie"
|
"github.com/OpenListTeam/OpenList/v4/pkg/cookie"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// 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 {
|
if e.Status >= 400 || e.Code != 0 {
|
||||||
return nil, errors.New(e.Message)
|
return nil, errors.New(e.Message)
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *QuarkOrUC) GetFiles(parent string) ([]model.Obj, error) {
|
func (d *QuarkOrUC) GetFiles(parent string) ([]model.Obj, error) {
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"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/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
"github.com/OpenListTeam/OpenList/v4/internal/errs"
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -82,7 +82,7 @@ func (d *QuarkUCTV) request(ctx context.Context, pathname string, method string,
|
|||||||
if e.Status >= 400 || e.Errno != 0 {
|
if e.Status >= 400 || e.Errno != 0 {
|
||||||
return nil, errors.New(e.ErrorInfo)
|
return nil, errors.New(e.ErrorInfo)
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *QuarkUCTV) getLoginCode(ctx context.Context) (string, error) {
|
func (d *QuarkUCTV) getLoginCode(ctx context.Context) (string, error) {
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Seafile struct {
|
type Seafile struct {
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *Seafile) getToken() error {
|
func (d *Seafile) getToken() error {
|
||||||
@ -68,7 +68,7 @@ func (d *Seafile) request(method string, pathname string, callback base.ReqCallb
|
|||||||
if res.StatusCode() >= 400 {
|
if res.StatusCode() >= 400 {
|
||||||
return nil, fmt.Errorf("request failed: %s", res.String())
|
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) {
|
func (d *Seafile) getRepoAndPath(fullPath string) (repo *LibraryInfo, path string, err error) {
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
"github.com/OpenListTeam/OpenList/v4/internal/driver"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Teambition struct {
|
type Teambition struct {
|
||||||
|
@ -18,8 +18,8 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// 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 != "" {
|
if e.Name != "" {
|
||||||
return nil, errors.New(e.Message)
|
return nil, errors.New(e.Message)
|
||||||
}
|
}
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Teambition) getFiles(parentId string) ([]model.Obj, error) {
|
func (d *Teambition) getFiles(parentId string) ([]model.Obj, error) {
|
||||||
|
@ -136,7 +136,7 @@ func (d *Terabox) Put(ctx context.Context, dstDir model.Obj, stream model.FileSt
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var locateupload_resp LocateUploadResp
|
var locateupload_resp LocateUploadResp
|
||||||
err = utils.Json.Unmarshal(resp.Body(), &locateupload_resp)
|
err = utils.Json.Unmarshal(resp.Bytes(), &locateupload_resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugln(resp)
|
log.Debugln(resp)
|
||||||
return err
|
return err
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -80,7 +80,7 @@ func (d *Terabox) request(rurl string, method string, callback base.ReqCallback,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
errno := utils.Json.Get(res.Body(), "errno").ToInt()
|
errno := utils.Json.Get(res.Bytes(), "errno").ToInt()
|
||||||
if errno == 4000023 {
|
if errno == 4000023 {
|
||||||
// reget jsToken
|
// reget jsToken
|
||||||
err = d.resetJsToken()
|
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 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) {
|
func (d *Terabox) get(pathname string, params map[string]string, resp interface{}) ([]byte, error) {
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Thunder struct {
|
type Thunder struct {
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -186,7 +186,7 @@ func (c *Common) Request(url, method string, callback base.ReqCallback, resp int
|
|||||||
}
|
}
|
||||||
|
|
||||||
var erron ErrResp
|
var erron ErrResp
|
||||||
utils.Json.Unmarshal(res.Body(), &erron)
|
utils.Json.Unmarshal(res.Bytes(), &erron)
|
||||||
if erron.IsError() {
|
if erron.IsError() {
|
||||||
// review_panel 表示需要短信验证码进行验证
|
// review_panel 表示需要短信验证码进行验证
|
||||||
if erron.ErrorMsg == "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 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 reviewResp LoginReviewResp
|
||||||
var reviewData ReviewData
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ThunderBrowser struct {
|
type ThunderBrowser struct {
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -227,7 +227,7 @@ func (c *Common) Request(url, method string, callback base.ReqCallback, resp int
|
|||||||
}
|
}
|
||||||
|
|
||||||
var erron ErrResp
|
var erron ErrResp
|
||||||
utils.Json.Unmarshal(res.Body(), &erron)
|
utils.Json.Unmarshal(res.Bytes(), &erron)
|
||||||
if erron.IsError() {
|
if erron.IsError() {
|
||||||
// review_panel 表示需要短信验证码进行验证
|
// review_panel 表示需要短信验证码进行验证
|
||||||
if erron.ErrorMsg == "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 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 reviewResp LoginReviewResp
|
||||||
var reviewData ReviewData
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ThunderX struct {
|
type ThunderX struct {
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
"github.com/OpenListTeam/OpenList/v4/drivers/base"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -208,12 +208,12 @@ func (c *Common) Request(url, method string, callback base.ReqCallback, resp int
|
|||||||
}
|
}
|
||||||
|
|
||||||
var erron ErrResp
|
var erron ErrResp
|
||||||
utils.Json.Unmarshal(res.Body(), &erron)
|
utils.Json.Unmarshal(res.Bytes(), &erron)
|
||||||
if erron.IsError() {
|
if erron.IsError() {
|
||||||
return nil, &erron
|
return nil, &erron
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.Body(), nil
|
return res.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算文件Gcid
|
// 计算文件Gcid
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
"github.com/OpenListTeam/OpenList/v4/internal/model"
|
||||||
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
"github.com/OpenListTeam/OpenList/v4/internal/op"
|
||||||
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
"github.com/OpenListTeam/wopan-sdk-go"
|
"github.com/OpenListTeam/wopan-sdk-go"
|
||||||
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Wopan struct {
|
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 {
|
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(),
|
Name: stream.GetName(),
|
||||||
Size: stream.GetSize(),
|
Size: stream.GetSize(),
|
||||||
Content: driver.NewLimitedUploadStream(ctx, stream),
|
Content: driver.NewLimitedUploadFile(ctx, file),
|
||||||
ContentType: stream.GetMimetype(),
|
ContentType: stream.GetMimetype(),
|
||||||
}, dstDir.GetID(), d.FamilyID, wopan.Upload2COption{
|
}, dstDir.GetID(), d.FamilyID, wopan.Upload2COption{
|
||||||
OnProgress: func(current, total int64) {
|
OnProgress: func(current, total int64) {
|
||||||
|
@ -10,7 +10,7 @@ type Object struct {
|
|||||||
FID string
|
FID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func fileToObj(file wopan.File) (model.Obj, error) {
|
func fileToObj(file *wopan.File) (model.Obj, error) {
|
||||||
t, err := getTime(file.CreateTime)
|
t, err := getTime(file.CreateTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user