Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion restapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func computeObjectURLWithoutEncode(bucketName, prefix string) (string, error) {
objectURL = path.Join(objectURL, bucketName)
}
if strings.TrimSpace(prefix) != "" {
objectURL = path.Join(objectURL, prefix)
objectURL = pathJoinFinalSlash(objectURL, prefix)
}

objectURL = fmt.Sprintf("%s://%s", u.Scheme, objectURL)
Expand Down Expand Up @@ -418,6 +418,16 @@ func newS3BucketClient(claims *models.Principal, bucketName string, prefix strin
return s3Client, nil
}

// pathJoinFinalSlash - like path.Join() but retains trailing slashSeparator of the last element
func pathJoinFinalSlash(elem ...string) string {
if len(elem) > 0 {
if strings.HasSuffix(elem[len(elem)-1], SlashSeparator) {
return path.Join(elem...) + SlashSeparator
}
}
return path.Join(elem...)
}

// newS3Config simply creates a new Config struct using the passed
// parameters.
func newS3Config(endpoint, accessKey, secretKey, sessionToken string, insecure bool) *mc.Config {
Expand Down
1 change: 1 addition & 0 deletions restapi/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ const (
ConsoleLogQueryURL = "CONSOLE_LOG_QUERY_URL"
ConsoleLogQueryAuthToken = "CONSOLE_LOG_QUERY_AUTH_TOKEN"
LogSearchQueryAuthToken = "LOGSEARCH_QUERY_AUTH_TOKEN"
SlashSeparator = "/"
)