feat: adds Location in CompleteMultipartUpload response

Closes #1714

There is a `Location` field in the `CompleteMultipartUpload` result that represents the newly created object URL. This PR adds this property to the `CompleteMultipartUpload` response, generating it dynamically in either host-style or path-style format, depending on the gateway configuration.
This commit is contained in:
niksis02
2025-12-29 13:39:54 +04:00
parent eb6ffca21e
commit f467b896d8
9 changed files with 77 additions and 18 deletions
+23
View File
@@ -887,3 +887,26 @@ func ValidateVersionId(versionId string) error {
return nil
}
// GenerateObjectLocation generates the object location path-styled or host-styled
// depending on the gateway configuration
func GenerateObjectLocation(ctx *fiber.Ctx, virtualDomain, bucket, object string) string {
scheme := ctx.Protocol()
host := ctx.Hostname()
// escape the object name
obj := url.PathEscape(object)
if virtualDomain != "" && strings.Contains(host, virtualDomain) {
// the host already contains the bucket name
return fmt.Sprintf("%s://%s/%s", scheme, host, obj)
}
return fmt.Sprintf(
"%s://%s/%s/%s",
scheme,
host,
bucket,
obj,
)
}