From 96f844347f6d24e471b32a5c266d9168dcdd1eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20OUDRY?= <107411+seboudry@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:39:07 +0100 Subject: [PATCH] fix(datastore): correct prefix to list with S3 storage (#376) --- 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)