Object access control lists (ACLs) include private, public read, and public read/write. This topic describes how to obtain the ACL of an object.

Object ACLs

The following table describes the three types of object ACLs.

Object ACL Description
Private Only the object owner and authorized users have read and write permissions on the object. Other users cannot access the object.
Public read Only the object owner and authorized users have read and write permissions on the object. Other users have only read permissions on the object. Exercise caution when you set the ACL of the object to this value.
Public read/write All users have read and write permissions on the object. Exercise caution when you set the ACL of the object to this value.

Examples

The following code provides an example on how to obtain the ACL of an object named exampleobject.txt in a bucket named examplebucket:

// Specify the bucket name such as examplebucket and the full path of the object such as exampledir/exampleobject.txt. The full path cannot contain the bucket name. 
GetObjectACLRequest request = new GetObjectACLRequest("examplebucket", "exampledir/exampleobject.txt");
// Obtain the ACL of the object. 
oss.asyncGetObjectACL(request, new OSSCompletedCallback<GetObjectACLRequest, GetObjectACLResult>() {
    @Override
    public void onSuccess(GetObjectACLRequest request, GetObjectACLResult result) {
        Log.d("GetObjectACL", "Success!");
        Log.d("ObjectAcl", result.getObjectACL());
        Log.d("Owner", result.getObjectOwner());
        Log.d("ID", result.getObjectOwnerID());
    }

    @Override
    public void onFailure(GetObjectACLRequest request, ClientException clientException, ServiceException serviceException) {
        // Handle request exceptions. 
        if (clientException != null) {
            // Handle client-side exceptions such as network errors. 
            clientException.printStackTrace();
        }
        if (serviceException != null) {
            // Handle server-side exceptions. 
            Log.e("ErrorCode", serviceException.getErrorCode());
            Log.e("RequestId", serviceException.getRequestId());
            Log.e("HostId", serviceException.getHostId());
            Log.e("RawMessage", serviceException.getRawMessage());
        }
    }
});

References

For more information about the API operation that you can call to obtain the ACL of an object, see GetObjectACL.