本文為您提供列出并讀取一個存儲空間中資源的參考示例。

  • 以下策略表示:您可以通過OSS SDK或OSS命令行工具列出并讀取一個存儲空間myphotos中的資源。
    {
        "Version": "1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": "oss:ListObjects",
                "Resource": "acs:oss:*:*:myphotos"
            },
            {
                "Effect": "Allow",
                "Action": "oss:GetObject",
                "Resource": "acs:oss:*:*:myphotos/*"
            }
        ]
    }
  • 以下策略表示:您可以通過OSS控制臺列出并讀取一個存儲空間myphotos中的資源。
    說明 為了操作體驗的優化,用戶登錄OSS控制臺時,OSS控制臺會額外調用ListBuckets、GetBucketAclGetObjectAcl,以確定存儲空間屬性是公開還是私有。
    {
        "Version": "1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                          "oss:ListBuckets",
                          "oss:GetBucketStat",
                          "oss:GetBucketInfo",
                          "oss:GetBucketTagging",
                          "oss:GetBucketAcl" 
                          ],    
                "Resource": "acs:oss:*:*:*"
            },
            {
                "Effect": "Allow",
                "Action": [
                    "oss:ListObjects",
                    "oss:GetBucketAcl"
                ],
                "Resource": "acs:oss:*:*:myphotos"
            },
            {
                "Effect": "Allow",
                "Action": [
                    "oss:GetObject",
                    "oss:GetObjectAcl"
                ],
                "Resource": "acs:oss:*:*:myphotos/*"
            }
        ]
    }