Skip to content

Commit

Permalink
feat: Add S3 Delete func (#71)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec authored Apr 22, 2022
1 parent f1072c4 commit ba30a5e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type S3Client interface {
// OpenFile opens a file for much lower disk and memory usage that GetFile
OpenFile(bucket, key string) (io.ReadCloser, error)

Delete(bucket, key string) error

// GetDirectory downloads a directory to a local file path
GetDirectory(bucket, key, path string) error

Expand Down Expand Up @@ -272,6 +274,11 @@ func (s *s3client) OpenFile(bucket, key string) (io.ReadCloser, error) {
return f, nil
}

func (s *s3client) Delete(bucket, key string) error {
log.WithFields(log.Fields{"endpoint": s.Endpoint, "bucket": bucket, "key": key}).Info("Deleting object from s3")
return s.minioClient.RemoveObject(s.ctx, bucket, key, minio.RemoveObjectOptions{})
}

// GetDirectory downloads a s3 directory to a local path
func (s *s3client) GetDirectory(bucket, keyPrefix, path string) error {
log.WithFields(log.Fields{"endpoint": s.Endpoint, "bucket": bucket, "key": keyPrefix, "path": path}).Info("Getting directory from s3")
Expand Down

0 comments on commit ba30a5e

Please sign in to comment.