Skip to content

Commit a29ef9d

Browse files
committed
update
1 parent ddbd39a commit a29ef9d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pkg/myaws/myaws.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,17 @@ func OpenS3(s3args []string) string {
4646
log.WithFields(
4747
log.Fields{
4848
"s3args": s3args,
49-
"str": str,
49+
"str": str,
5050
}).Debug()
5151
if len(str) > 1 {
52-
// objects
52+
if str[1][len(str[1])-1:len(str[1])] == "/" {
53+
// buckets
54+
u.Path += "buckets/" + str[0]
55+
} else {
56+
// objects
57+
u.Path += "object/" + str[0]
58+
}
5359
q.Set("prefix", str[1])
54-
u.Path += "object/" + str[0]
5560
} else {
5661
// buckets
5762
u.Path += "buckets/" + str[0]

pkg/myaws/myaws_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ func TestOpenS3(t *testing.T) {
3333
input: []string{"cf-templates-xxxxxxxxx-ap-northeast-1", "permissions"},
3434
want: "https://s3.console.aws.amazon.com/s3/buckets/cf-templates-xxxxxxxxx-ap-northeast-1?tab=permissions",
3535
},
36+
{
37+
input: []string{"cf-templates-xxxxxxxxx-ap-northeast-1/2021/01/01/"},
38+
want: "https://s3.console.aws.amazon.com/s3/buckets/cf-templates-xxxxxxxxx-ap-northeast-1?prefix=2021%2F01%2F01%2F",
39+
},
3640
}
3741

3842
for _, v := range a {

0 commit comments

Comments
 (0)