Browse Source

versionId vs versions

pull/7479/head
chrislu 4 weeks ago
parent
commit
73effa041d
  1. 24
      weed/s3api/s3_action_resolver.go
  2. 6
      weed/s3api/s3_list_parts_action_test.go

24
weed/s3api/s3_action_resolver.go

@ -149,19 +149,23 @@ func resolveFromQueryParameters(query url.Values, method string, hasObject bool)
}
}
if query.Has("versions") {
if method == http.MethodGet {
// If there's an object, this is GetObjectVersion
// If there's no object (bucket level), this is ListBucketVersions
if hasObject {
// Versioning operations - distinguish between versionId (specific version) and versions (list versions)
// versionId: Used to access/delete a specific version of an object (e.g., GET /bucket/key?versionId=xyz)
if query.Has("versionId") {
if hasObject {
switch method {
case http.MethodGet, http.MethodHead:
return s3_constants.S3_ACTION_GET_OBJECT_VERSION
} else {
return s3_constants.S3_ACTION_LIST_BUCKET_VERSIONS
case http.MethodDelete:
return s3_constants.S3_ACTION_DELETE_OBJECT_VERSION
}
}
// DELETE with versions could be DeleteObjectVersion
if method == http.MethodDelete && hasObject {
return s3_constants.S3_ACTION_DELETE_OBJECT_VERSION
}
// versions: Used to list all versions of objects in a bucket (e.g., GET /bucket?versions)
if query.Has("versions") {
if method == http.MethodGet && !hasObject {
return s3_constants.S3_ACTION_LIST_BUCKET_VERSIONS
}
}

6
weed/s3api/s3_list_parts_action_test.go

@ -57,14 +57,14 @@ func TestListPartsActionMapping(t *testing.T) {
description: "GET request with uploadId plus other multipart params should map to s3:ListParts",
},
{
name: "get_object_versions",
name: "get_object_with_versionId",
method: "GET",
bucket: "test-bucket",
objectKey: "test-object.txt",
queryParams: map[string]string{"versions": ""},
queryParams: map[string]string{"versionId": "version-123"},
fallbackAction: s3_constants.ACTION_READ,
expectedAction: "s3:GetObjectVersion",
description: "GET request with versions should still map to s3:GetObjectVersion (precedence check)",
description: "GET request with versionId should map to s3:GetObjectVersion",
},
{
name: "get_object_acl_without_uploadId",

Loading…
Cancel
Save