我有以下脚本将所有文件从 c:\ images 复制到 mybucket \ myfolder
如何反向并从 mybucket \ myfolder 复制到 c:\ images ?
$key = "mykey"
$secret = "mysecret"
$cbsnap = "CloudBerryLab.Explorer.PSSnapIn"
if ( (Get-PSSnapin -Name $cbsnap -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin $cbsnap
}
Set-CloudOption -PermissionsInheritance "inheritall"
$s3 = Get-CloudS3Connection -Key $key -Secret $secret
Set-Logging –LogPath c:\temp\sync.log -LogLevel info
$bucket = "mybucket\myfolder"
$local = "c:\images\"
#copy from local to S3
$s3selflhost = $s3 | Select-CloudFolder -path $bucket
$src = Get-CloudFilesystemConnection | Select-CloudFolder -path $local
$src | Copy-CloudItem $s3selflhost -filter "*"
答案 0 :(得分:1)
只需切换表示S3和本地磁盘上文件夹的参数:
$s3selflhost | Copy-CloudItem $src -filter "*"
实际上这只是以下命令的流水线版本:
Copy-CloudItem -Destination $src -filter "*" -Folder $s3selflhost
因此,您实际上切换了目标和源文件夹参数。