gpt4 book ai didi

amazon-web-services - 写入 S3Object : The file indicated by the FilePath property does not exist

转载 作者:行者123 更新时间:2023-12-02 23:53:14 30 4
gpt4 key购买 nike

我正在编写一个 powershell 脚本,它将由 robocopy 脚本创建的文本文件中列出的文件名上传到 S3 存储桶,但我似乎无法获得 Write-S3Object 命令的语法写入。

这是我的代码,我希望你能帮我调试它:

foreach($line in Get-Content C:\Scripts\ToS3\FileList1.txt) {
if($line -match $regex){
$key = $line -replace [regex]::Escape('\\server\e$\'), '/' -replace
"c:\\", "s3://mybucket/" -replace "\\","/" -replace " `t","" -replace "`t",""
$file = $line -replace " `t","" -replace "`t",""
write-output `"$file`"
write-output `"$key`"
Write-S3Object -BucketName mybucket -File `"$file`" -Key `"$key`" -ProfileName xxxx
}
}

无论出于何种原因 $file 都没有正确加载,尽管它在写入输出中显示得很好。给了什么?

所有替换命令都用于生成 robocopy 输出:

\server\e$\Data\example folder 1\example folder 2\another file 2.txt

到S3格式:

s3://mybucket/Data/example folder 1/example folder 2/another file 2.txt

最佳答案

Write-S3Object 不理解 s3://语法。只需将存储桶名称(给 -BucketName 参数)和本地文件名给 -File 参数即可。如果您不为 -Key 提供值,将使用文件名。

关于amazon-web-services - 写入 S3Object : The file indicated by the FilePath property does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53093709/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com