我有一个powershell脚本,它在访问普通的S3桶时可以工作,但是如果我将桶名更改为传输加速桶名,那么它就会出现一个错误"Bucket“。
包括与注释掉的桶名不起作用的脚本。
# Your account access key - must have read access to your S3 Bucket
$accessKey = "KEY"
# Your account secret access key
$secretKey = "SECRETKEY"
#
$region = "us-east-1"
# The name of your S3 Bucket
$bucket = "myBucket"
#The above works!! - but if i comment out the above and uncomment
the below line then it no longer works.
#$bucket = "myBucket.s3-accelerate.amazonaws.com"
# The folder in your bucket to copy, including trailing slash. Leave
blank to copy the entire bucket
$keyPrefix = "myFolder/"
# The local file path where files should be copied
$localPath = "D:\S3_Files\myFolder\"
$objects = Get-S3Object -BucketName $bucket -KeyPrefix $keyPrefix -
AccessKey $accessKey -SecretKey $secretKey -Region $region
foreach($object in $objects) {
$localFileName = $object.Key -replace $keyPrefix, ''
if ($localFileName -ne '') {
$localFilePath = Join-Path $localPath $localFileName
Copy-S3Object -BucketName $bucket -Key $object.Key -LocalFile $localFilePath -AccessKey $accessKey -SecretKey $secretKey -Region $region
}
}发布于 2019-02-11 19:21:54
不要为存储桶指定S3加速名称,只需使用普通的桶名并将-UseAccelerateEndpoint开关添加到S3命令中即可。然后,cmdlet将为您锁定加速的S3端点。
https://stackoverflow.com/questions/54412997
复制相似问题