mirror of
https://github.com/versity/versitygw.git
synced 2026-08-20 22:26:19 +00:00
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:
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user