This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
forked from minio/minio-go
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from sendgrid/cp-3105-add-remote-addr
Merged by opsbot at Eric Choi's request
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |