Skip to content

Commit 07fce2a

Browse files
committed
Improve s3 helpers
1 parent f9e6dc9 commit 07fce2a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/lib/aws/s3.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ func (c *Client) UploadMsgpackToS3(obj interface{}, bucket string, key string) e
383383
return c.UploadBytesToS3(msgpackBytes, bucket, key)
384384
}
385385

386+
func (c *Client) CreateEmptyS3File(bucket string, key string) error {
387+
return c.UploadReaderToS3(bytes.NewReader(nil), bucket, key)
388+
}
389+
386390
func (c *Client) UploadDirToS3(localDirPath string, bucket string, s3Dir string, ignoreFns ...files.IgnoreFn) error {
387391
localRelPaths, err := files.ListDirRecursive(localDirPath, true, ignoreFns...)
388392
if err != nil {
@@ -705,6 +709,7 @@ func (c *Client) DeleteS3Dir(bucket string, s3Dir string, continueIfFailure bool
705709
}
706710

707711
func (c *Client) DeleteS3Prefix(bucket string, prefix string, continueIfFailure bool) error {
712+
// This implementation is confirmed to be considerably faster than using s3manager.NewDeleteListIterator() + s3manager.NewBatchDeleteWithClient()
708713
err := c.S3BatchIterator(bucket, prefix, true, nil, func(objects []*s3.Object) (bool, error) {
709714
deleteObjects := make([]*s3.ObjectIdentifier, len(objects))
710715
for i, object := range objects {

0 commit comments

Comments
 (0)