当我这样做:
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并查看我帐户中的所有存储桶,因此我知道它已正确配置.
如果我做:
> $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
单独做,我会得到对象的完整路径.但是,它有空格.这可能是个问题吗?