In v1 of the SDK, copying over object ACL while copying an object was fairly easy.
Assuming we already had a CopyObjectRequest named req, this was all the additional code that was necessary.
AccessControlList acl = s3.getObjectAcl(bucketName, oldObjectName);
req.setAccessControlList(acl);
Now getObjectAcl returns a GetObjectAclResponse, and CopyObjectRequest only takes canned ACL. There's no way to directly copy it over. It appears I have to manually copy the fields of the GetObjectAclResponse to an AccessControlPolicy, then pass that to a separate PutObjectAclRequest. Not only is this more code, but it isn't very discoverable. It wasn't obvious how to go from a GetObjectAclResponse to something that could be set on another object.
I'd like there to be an easier way to copy ACL over when copying an S3 object using the v2 SDK.
In v1 of the SDK, copying over object ACL while copying an object was fairly easy.
Assuming we already had a
CopyObjectRequestnamedreq, this was all the additional code that was necessary.Now
getObjectAclreturns aGetObjectAclResponse, andCopyObjectRequestonly takes canned ACL. There's no way to directly copy it over. It appears I have to manually copy the fields of theGetObjectAclResponseto anAccessControlPolicy, then pass that to a separatePutObjectAclRequest. Not only is this more code, but it isn't very discoverable. It wasn't obvious how to go from aGetObjectAclResponseto something that could be set on another object.I'd like there to be an easier way to copy ACL over when copying an S3 object using the v2 SDK.