当我这样做时:
foreach ($f in (Get-ChildItem -filter "*.flv")){
Write-S3Object -BucketName bucket.example -File $f.fullName -Key $f.name -CannedACLName PublicRead
}
我收到此错误:
Write-S3Object :
At line:1 char:51
+ foreach ($f in (Get-ChildItem -filter "*.flv")){ Write-S3Object -BucketName xx. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Amazon.PowerShe...eS3ObjectCmdlet:WriteS3ObjectCmdlet) [Write-S3Objec
t], InvalidOperationException
+ FullyQualifiedErrorId : Amazon.S3.AmazonS3Exception,Amazon.PowerShell.Cmdlets.S3.WriteS3ObjectCmdlet
我究竟做错了什么?我可以做些什么来查看更多错误,或者这只是语法问题?
我如何才能使用 powershell 将所有特定文件类型上传到存储桶?
编辑:
我故意设置Set-DefaultAWSRegion
到桶不在的区域,然后得到
Write-S3Object : The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
正如预期的那样,作为错误消息,因此它看起来可以连接到存储桶并且它知道它不在某个区域中。
另外,如果我 s3://
在存储桶名称之前输入前缀,我会收到一条消息,提示找不到存储桶,所以看起来我现在输入的内容是正确的。
我可以执行 Get-S3Bucket 并查看我帐户中的所有存储桶,因此我知道它已正确配置。
编辑2:
如果我做:
> $f = Get-ChildItem -filter "*.flv"
> Write-S3Object
cmdlet Write-S3Object at command pipeline position 1
Supply values for the following parameters:
BucketName: bucket.name
Key: $f[0].name
File: $f[0].fullName
Write-S3Object : The file indicated by the FilePath property does not exist!
At line:1 char:1
+ Write-S3Object
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Amazon.PowerShe...eS3ObjectCmdlet:WriteS3ObjectCmdlet) [Write-S3Objec
t], InvalidOperationException
+ FullyQualifiedErrorId : System.ArgumentException,Amazon.PowerShell.Cmdlets.S3.WriteS3ObjectCmdlet
如果我$f[0].fullName
单独做,我会得到对象的完整路径。但是,这里面有空格。这会是个问题吗?