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. |
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 name of the bucket and the full path of the object. In this example, the name of the bucket is examplebucket and the full path of the object is exampledir/exampleobject.txt. Do not include the bucket name in the full path.
GetObjectACLRequest request = new GetObjectACLRequest("examplebucket", "exampledir/exampleobject.txt");
// You cannot configure the ACL of an object by using OSS SDK for Android. You can only obtain the ACL of an object by using OSS SDK for Android.
// The following sample code provides an example on how to query 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) {
// 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 query the ACL of an object, see GetObjectACL.
For more information about how to initialize an OSSClient instance, see Initialization.