fix(teambition): empty token for upload (close #3854)

This commit is contained in:
Andy Hsu 2023-03-15 14:56:41 +08:00
parent 443f5ffbcc
commit a1e88cfa05
2 changed files with 4 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/go-resty/resty/v2"
)
@ -124,11 +125,11 @@ func (d *Teambition) Remove(ctx context.Context, obj model.Obj) error {
}
func (d *Teambition) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
res, err := d.request("/projects", http.MethodGet, nil, nil)
res, err := d.request("/api/v2/users/me", http.MethodGet, nil, nil)
if err != nil {
return err
}
token := GetBetweenStr(string(res), "strikerAuth":"", "","phoneForLogin")
token := utils.Json.Get(res, "strikerAuth").ToString()
var newFile *FileUpload
if stream.GetSize() <= 20971520 {
// post upload

View File

@ -210,7 +210,7 @@ func (d *Teambition) finishUpload(file *FileUpload, parentId string) error {
return err
}
func GetBetweenStr(str, start, end string) string {
func getBetweenStr(str, start, end string) string {
n := strings.Index(str, start)
if n == -1 {
return ""