This topic uses an example policy to demonstrate how to access and list specified files through Object Storage Service (OSS) CLI.

The following policy indicates that the authorized RAM user can use OSS CLI to access the myphotos/hangzhou/2015/ directory and list the files in this directory.

Note The RAM user does not know what files are stored in the directory, but can use OSS CLI or call API operations to obtain the directory information. We recommend that you attach this policy to your software developers.
{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "oss:GetObject"
            ],
            "Resource": [
                "acs:oss:*:*:myphotos/hangzhou/2015/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "oss:ListObjects"
            ],
            "Resource": [
                "acs:oss:*:*:myphotos"
            ],
            "Condition":{
                "StringLike":{
                    "oss:Prefix":"hangzhou/2015/*"
                }
            }
        }
    ]
}