Skip to content

Commit

Permalink
fix b2 copy (#3594)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored and SandyXSD committed Aug 23, 2023
1 parent 00d34eb commit 2e51abb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/object/b2.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func (c *b2client) Copy(dst, src string) error {
if err != nil {
return err
}
_, err = c.bucket.CopyFile(f.ID, dst, "", backblaze.FileMetaDirectiveCopy)
// destinationBucketId must be set,otherwise it will return 400 Bad destinationBucketId
_, err = c.bucket.CopyFile(f.ID, dst, c.bucket.ID, backblaze.FileMetaDirectiveCopy)
return err
}

Expand Down Expand Up @@ -171,6 +172,8 @@ func newB2(endpoint, keyID, applicationKey, token string) (ObjectStorage, error)
bucket, err := client.Bucket(name)
if err != nil {
logger.Warnf("access bucket %s: %s", name, err)
}
if err == nil && bucket == nil {
bucket, err = client.CreateBucket(name, "allPrivate")
if err != nil {
return nil, fmt.Errorf("create bucket %s: %s", name, err)
Expand Down

0 comments on commit 2e51abb

Please sign in to comment.