Skip to content

Commit

Permalink
fix(123): incorrect endpoint (close #4046)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Apr 12, 2023
1 parent 0270253 commit fdcad9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/123/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,20 @@ func (d *Pan123) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
"type": 0,
}
var resp UploadResp
_, err := d.request(UploadRequest, http.MethodPost, func(req *resty.Request) {
res, err := d.request(UploadRequest, http.MethodPost, func(req *resty.Request) {
req.SetBody(data).SetContext(ctx)
}, &resp)
if err != nil {
return err
}
log.Debugln("upload request res: ", string(res))
if resp.Data.Reuse || resp.Data.Key == "" {
return nil
}
cfg := &aws.Config{
Credentials: credentials.NewStaticCredentials(resp.Data.AccessKeyId, resp.Data.SecretAccessKey, resp.Data.SessionToken),
Region: aws.String("123pan"),
Endpoint: aws.String("file.123pan.com"),
Endpoint: aws.String(resp.Data.EndPoint),
S3ForcePathStyle: aws.Bool(true),
}
s, err := session.NewSession(cfg)
Expand Down
1 change: 1 addition & 0 deletions drivers/123/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@ type UploadResp struct {
SessionToken string `json:"SessionToken"`
FileId int64 `json:"FileId"`
Reuse bool `json:"Reuse"`
EndPoint string `json:"EndPoint"`
} `json:"data"`
}

0 comments on commit fdcad9c

Please sign in to comment.