Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #7 from sendgrid/cp-3105-add-remote-addr
Browse files Browse the repository at this point in the history
Merged by opsbot at Eric Choi's request
  • Loading branch information
sgopsbot authored Aug 2, 2019
2 parents 9729e1f + c7d7740 commit 7c83226
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions api-remove-context.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package minio

import (
"context"
"net/http"

"github.com/minio/minio-go/pkg/s3utils"
)

// RemoveObjectWithContext is copied from RemoveObject, but it takes a context
func (c Client) RemoveObjectWithContext(ctx context.Context, bucketName, objectName string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return err
}

// Execute DELETE on objectName.
resp, err := c.executeMethod(ctx, "DELETE", requestMetadata{
bucketName: bucketName,
objectName: objectName,
contentSHA256Hex: emptySHA256Hex,
})
defer closeResponse(resp)
if err != nil {
return err
}
if resp != nil {
// if some unexpected error happened and max retry is reached, we want to let client know
if resp.StatusCode != http.StatusNoContent {
return httpRespToErrorResponse(resp, bucketName, objectName)
}
}

// DeleteObject always responds with http '204' even for
// objects which do not exist. So no need to handle them
// specifically.
return nil
}

0 comments on commit 7c83226

Please sign in to comment.