All Products
Search
Document Center

Object Storage Service:Get the ACL of an object (Android SDK)

Last Updated:Nov 29, 2025

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

Usage notes

  • Before you run the sample code in this topic, you must create an OSSClient instance by using methods such as using a custom domain name or Security Token Service (STS). For more information, see Initialization.

Object ACLs

There are three types of file access permissions:

File access permissions

Description

Private

Only the object owner and authorized users have read and write permissions on 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 object ACL to this value.

Public-read-write

All users have read and write permissions on the object. Exercise caution when you set the object ACL to this value.

Examples

The following sample 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 and the full path of the object. Example: examplebucket and exampledir/exampleobject.txt. The full path of the object cannot contain the bucket name.
GetObjectACLRequest request = new GetObjectACLRequest("examplebucket", "exampledir/exampleobject.txt");
// OSS SDK for Android does not support setting object ACLs. You can only get object ACLs.
// The following code shows how to get the ACL of an 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) {
        // Request exceptions.
        if (clientException != null) {
            // Client exceptions, such as network exceptions.
            clientException.printStackTrace();
        }
        if (serviceException != null) {
            // Server 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 query the ACL of an object, see GetObjectACL.

  • For more information about how to initialize an OSSClient instance, see Initialization.