diff --git a/drivers/123/driver.go b/drivers/123/driver.go index 48bf0c09..baa0be9a 100644 --- a/drivers/123/driver.go +++ b/drivers/123/driver.go @@ -4,9 +4,9 @@ import ( "bytes" "context" "crypto/md5" + "encoding/base64" "encoding/binary" "encoding/hex" - "encoding/base64" "fmt" "io" "net/http" @@ -229,13 +229,13 @@ func (d *Pan123) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr "type": 0, } var resp UploadResp - _, err := d.request("https://www.123pan.com/api/file/upload_request", http.MethodPost, func(req *resty.Request) { + _, err := d.request("https://www.123pan.com/a/api/file/upload_request", http.MethodPost, func(req *resty.Request) { req.SetBody(data) }, &resp) if err != nil { return err } - if resp.Data.Key == "" { + if resp.Data.Reuse || resp.Data.Key == "" { return nil } cfg := &aws.Config{ diff --git a/drivers/123/types.go b/drivers/123/types.go index 6e0c96a9..48ee4fc5 100644 --- a/drivers/123/types.go +++ b/drivers/123/types.go @@ -85,5 +85,6 @@ type UploadResp struct { SecretAccessKey string `json:"SecretAccessKey"` SessionToken string `json:"SessionToken"` FileId int64 `json:"FileId"` + Reuse bool `json:"Reuse"` } `json:"data"` } diff --git a/drivers/123/util.go b/drivers/123/util.go index cfb225cf..185977c5 100644 --- a/drivers/123/util.go +++ b/drivers/123/util.go @@ -15,7 +15,7 @@ import ( func (d *Pan123) login() error { var body base.Json - url := "https://www.123pan.com/api/user/sign_in" + url := "https://www.123pan.com/a/api/user/sign_in" if utils.IsEmailFormat(d.Username) { body = base.Json{ "mail": d.Username, @@ -45,7 +45,12 @@ func (d *Pan123) login() error { func (d *Pan123) request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) { req := base.RestyClient.R() - req.SetHeader("Authorization", "Bearer "+d.AccessToken) + req.SetHeaders(map[string]string{ + "origin": "https://www.123pan.com", + "authorization": "Bearer " + d.AccessToken, + "platform": "web", + "app-version": "1.2", + }) if callback != nil { callback(req) }