What do I do if the object ACL configurations for resumable upload operations do not take effect?

更新时间:
复制 MD 格式

Problem description

When using OSS SDK for Java, object access control list (ACL) configurations set during a resumable upload operation do not take effect.

Causes

Resumable upload operations in OSS SDK for Java do not support configuring object ACL. Any ACL value passed through ObjectMetadata during a resumable upload is not applied to the uploaded object.

Examples

The following two code patterns both fail — the ACL is not applied to the uploaded object.

Pattern 1: Setting ACL via `setObjectAcl()`

ObjectMetadata objectMeta = new ObjectMetadata();
objectMeta.setObjectAcl(CannedAccessControlList.PublicRead);
uploadFileRequest.setObjectMetadata(objectMeta);

Pattern 2: Setting ACL via the `x-oss-object-acl` header

objectMeta.setHeader("x-oss-object-acl", "public-read");
uploadFileRequest.setObjectMetadata(objectMeta);

Solution

After the upload completes, call setObjectAcl to set the object ACL.