无法使用sync将文件夹中的对象移动到使用s3cmd的同一存储桶中的另一个文件夹

时间:2015-08-07 11:50:50

标签: amazon-web-services amazon-s3 s3cmd

我一直在尝试将文件夹bucketA/product/pic/中的所有对象向上移动到同一个文件夹中的一个级别bucketA/pic/

我可以使用

在本地主机和s3服务器之间同步文件
s3cmd sync /script/ s3://bucketA/ 

以及放置一个对象:

s3cmd put zip.sh s3://bucketA/

但在同一个存储桶中同步文件时,我遇到Access Denied错误:

[root]s3cmd sync s3://bucketA/product/pic s3://bucketA/pic/

WARNING: Empty object name on S3 found, ignoring.
Summary: 441 source files to copy, 0 files at destination to delete
ERROR: S3 error: Access Denied

是否可以更改同一存储桶中文件夹中对象的位置?

这是我的IAM政策:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt123456",
            "Effect": "Allow",
            "Action": [
                "s3:ListAllMyBuckets"
            ],
            "Resource": [
                "arn:aws:s3:::*"
            ]
        },
        {
            "Sid": "Stmt123457",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:GetBucketLocation"
            ],
            "Resource": [
                "arn:aws:s3:::bucketA",
                "arn:aws:s3:::bucketA/*"
            ]
        }
    ]
}

这是我的存储桶策略,设置为阻止热链接:

{
    "Version": "2012-10-17",
    "Id": "HTTP referrer policy",
    "Statement": [
        {
            "Sid": "Allow in my domains",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::bucketA/*",
            "Condition": {
                "StringLike": {
                    "aws:Referer": [
                        "https://mylocalhostip/*",
                        "http://mylocalhostip/*"

                    ]
                }
            }
        },
        {
            "Sid": "Deny access if referer is not my sites",
            "Effect": "Deny",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::bucketA/*",
            "Condition": {
                "StringNotLike": {
                    "aws:Referer": [
                        "http://mylocalhostip/*",
                        "https://mylocalhostip/*"

                    ]
                }
            }
        }
    ]
}

1 个答案:

答案 0 :(得分:1)

目前,建议使用AWS Command-Line Interface (CLI)

AWS CLI包含sync命令。请参阅:https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html