Skip to content

Commit

Permalink
fix(pikpak):fix webdav upload issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Three-taile-dragon committed Aug 21, 2024
1 parent 18176c6 commit f531f7e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions drivers/pikpak/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,16 @@ func (d *PikPak) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
}

params := resp.Resumable.Params
endpoint := strings.Join(strings.Split(params.Endpoint, ".")[1:], ".")
//endpoint := strings.Join(strings.Split(params.Endpoint, ".")[1:], ".")
// 测试下来 返回的 "endpoint" 有两种情况,一种是 "mypikpak.com" 另一种是 bucket + “mypikpak.com” 例如 "vip-lixian-07.mypikpak.com"
// 暂时统一处理为 bucket + “mypikpak.com”
endpoint := params.Bucket + ".mypikpak.com"
cfg := &aws.Config{
Credentials: credentials.NewStaticCredentials(params.AccessKeyID, params.AccessKeySecret, params.SecurityToken),
Region: aws.String("pikpak"),
Endpoint: &endpoint,
HTTPClient: base.HttpClient,
Credentials: credentials.NewStaticCredentials(params.AccessKeyID, params.AccessKeySecret, params.SecurityToken),
Region: aws.String("pikpak"),
Endpoint: aws.String(endpoint),
S3ForcePathStyle: aws.Bool(true),
}
ss, err := session.NewSession(cfg)
if err != nil {
Expand All @@ -286,8 +291,8 @@ func (d *PikPak) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
uploader.PartSize = stream.GetSize() / (s3manager.MaxUploadParts - 1)
}
input := &s3manager.UploadInput{
Bucket: &params.Bucket,
Key: &params.Key,
Bucket: aws.String(params.Bucket),
Key: aws.String(params.Key),
Body: io.TeeReader(stream, driver.NewProgress(stream.GetSize(), up)),
}
_, err = uploader.UploadWithContext(ctx, input)
Expand Down

0 comments on commit f531f7e

Please sign in to comment.