-
Notifications
You must be signed in to change notification settings - Fork 761
Open
Labels
S-reproducingStatus: Reproducing a bug reportStatus: Reproducing a bug reportbugSomething isn't workingSomething isn't working
Description
is there anyway to delete folder(empty) by aws sdk?
import (
"bytes"
"context"
"errors"
"log"
"testing"
"gitee.com/cruvie/kk_go_kit/kk_stage"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/credentials"
s3 "github.com/aws/aws-sdk-go-v2/service/s3"
)
func TestDeleteObject(t *testing.T) {
objects := []DeleteObjectInput{
{
BucketName: "ccc",
ObjectName: "fafafa",
},
{
BucketName: "ccc",
ObjectName: "fafafa/",
},
}
for _, object := range objects {
DeleteObject(object)
}
}
type DeleteObjectInput struct {
BucketName string
ObjectName string
}
func DeleteObject(input DeleteObjectInput) (err error) {
cfg := aws.Config{
Region: "c.Region",
BaseEndpoint: aws.String("http://127.0.0.1:9000"),
Credentials: aws.NewCredentialsCache(credentials.NewStaticCredentialsProvider("", "", "")),
}
S3Client := s3.NewFromConfig(cfg, func(o *s3.Options) {
o.UsePathStyle = true
})
if input.BucketName == "" || input.ObjectName == "" {
return errors.New("required parameter is empty")
}
_, err = S3Client.DeleteObject(context.Background(), &s3.DeleteObjectInput{
Bucket: &input.BucketName,
Key: &input.ObjectName,
})
if err != nil {
return err
}
return nil
}moray95
Metadata
Metadata
Labels
S-reproducingStatus: Reproducing a bug reportStatus: Reproducing a bug reportbugSomething isn't workingSomething isn't working
