无法使用 sync 使用 s3cmd 将文件夹中的对象移动到同一存储桶中的另一个文件夹
Can't use sync to move objects in a folder to another folder within the same bucket using 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/*"
]
}
}
}
]
}
这几天,推荐使用AWS Command-Line Interface (CLI)。
AWS CLI 包含一个 sync
命令。参见:https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
我一直在尝试将文件夹 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/*"
]
}
}
}
]
}
这几天,推荐使用AWS Command-Line Interface (CLI)。
AWS CLI 包含一个 sync
命令。参见:https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html