Skip to content

Commit

Permalink
[s3] Refactor DeleteObject (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
evalphobia authored Dec 11, 2020
1 parent e5e03df commit 2584fc7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions s3/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,25 +254,25 @@ func (b *Bucket) CopyFrom(srcBucket, srcPath, destPath string, opt ...CopyObject

// DeleteObject deletes the object of target path.
func (b *Bucket) DeleteObject(path string) error {
_, err := b.service.client.DeleteObject(&SDK.DeleteObjectInput{
return b.deleteObject(&SDK.DeleteObjectInput{
Bucket: pointers.String(b.nameWithPrefix),
Key: pointers.String(path),
})
if err != nil {
b.service.Errorf("error on `GetObject` operation; bucket=%s; error=%s;", b.nameWithPrefix, err.Error())
}
return err
}

// DeleteObject deletes the object of target path and versionId.
func (b *Bucket) DeleteObjectWithVersionId(path string, versionId string) error {
_, err := b.service.client.DeleteObject(&SDK.DeleteObjectInput{
// DeleteObjectWithVersionID deletes the object of target path and versionId.
func (b *Bucket) DeleteObjectWithVersionID(path string, versionID string) error {
return b.deleteObject(&SDK.DeleteObjectInput{
Bucket: pointers.String(b.nameWithPrefix),
Key: pointers.String(path),
VersionId: pointers.String(versionId),
VersionId: pointers.String(versionID),
})
}

func (b *Bucket) deleteObject(in *SDK.DeleteObjectInput) error {
_, err := b.service.client.DeleteObject(in)
if err != nil {
b.service.Errorf("error on `DeleteObjectWithVersionId` operation; bucket=%s; error=%s;", b.nameWithPrefix, err.Error())
b.service.Errorf("error on `DeleteObject` operation; bucket=%s; error=%s;", b.nameWithPrefix, err.Error())
}
return err
}

0 comments on commit 2584fc7

Please sign in to comment.