Skip to content

Commit 9079d2d

Browse files
authored
fix: fix the illegal character code error when list objects
* fix: fix the illegal character code error when list objects * chore: remove useless code
1 parent c90bc89 commit 9079d2d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

dth/client.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"fmt"
2525
"io"
2626
"log"
27+
"net/url"
2728
"strings"
2829
"sync"
2930
"time"
@@ -173,6 +174,7 @@ func (c *S3Client) listObjectFn(ctx context.Context, continuationToken, prefix,
173174
Prefix: prefix,
174175
MaxKeys: maxKeys,
175176
Delimiter: delimiter,
177+
EncodingType: "url",
176178
}
177179

178180
if *continuationToken != "" {
@@ -280,8 +282,12 @@ func (c *S3Client) ListObjects(ctx context.Context, continuationToken, prefix *s
280282
if obj.StorageClass == "GLACIER" || obj.StorageClass == "DEEP_ARCHIVE" {
281283
continue
282284
}
285+
escapedPrefix, err := url.QueryUnescape(*obj.Key)
286+
if err != nil {
287+
escapedPrefix = *obj.Key
288+
}
283289
result = append(result, &Object{
284-
Key: *obj.Key,
290+
Key: escapedPrefix,
285291
Size: obj.Size,
286292
})
287293
}

0 commit comments

Comments
 (0)