我要求将文件从简单存储服务下载到本地文件夹,并计算本地文件夹中的no.of文件并检查简单存储服务,然后发送包含文件数量的邮件.
我试图从简单的存储服务下载文件,但我收到的错误就像get-s3object commandnotfoundexception
.我该如何解决这个问题?
代码参考我已经采取
# Your account access key - must have read access to your S3 Bucket $accessKey = "YOUR-ACCESS-KEY" # Your account secret access key $secretKey = "YOUR-SECRET-KEY" # The region associated with your bucket e.g. eu-west-1, us-east-1 etc. (see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-regions) $region = "eu-west-1" # The name of your S3 Bucket $bucket = "my-test-bucket" # The folder in your bucket to copy, including trailing slash. Leave blank to copy the entire bucket $keyPrefix = "my-folder/" # The local file path where files should be copied $localPath = "C:\s3-downloads\" $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 } }
Will.. 9
由于此问题是“ powershell下载s3文件”的Google最高搜索结果之一,因此我将在标题中回答该问题(即使实际问题文本不同):
Read-S3Object -BucketName "my-s3-bucket" -KeyPrefix "path/to/directory" -Folder .
Set-AWSCredentials
如果它不是公共存储桶,则可能需要致电。
由于此问题是“ powershell下载s3文件”的Google最高搜索结果之一,因此我将在标题中回答该问题(即使实际问题文本不同):
Read-S3Object -BucketName "my-s3-bucket" -KeyPrefix "path/to/directory" -Folder .
Set-AWSCredentials
如果它不是公共存储桶,则可能需要致电。