From 4986e84cf01af08d174a7163a4481596d750159d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20OUDRY?= <107411+seboudry@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:13:53 +0100 Subject: [PATCH] fix(datastore): correct prefix to list with S3 storage --- internal/datastore/storage/s3/s3.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/datastore/storage/s3/s3.go b/internal/datastore/storage/s3/s3.go index 4816ff00..e0c2d214 100644 --- a/internal/datastore/storage/s3/s3.go +++ b/internal/datastore/storage/s3/s3.go @@ -3,7 +3,9 @@ package s3 import ( "bytes" "context" + "fmt" "io" + "strings" sdk "github.com/aws/aws-sdk-go-v2/config" storage "github.com/aws/aws-sdk-go-v2/service/s3" @@ -86,7 +88,7 @@ func (a *S3) Delete(key string) error { func (a *S3) List(prefix string) ([]string, error) { input := &storage.ListObjectsV2Input{ Bucket: &a.Config.Bucket, - Prefix: &prefix, + Prefix: aws.String(fmt.Sprintf("%s/", strings.TrimPrefix(prefix, "/"))), Delimiter: aws.String("/"), } result, err := a.Client.ListObjectsV2(context.TODO(), input)