我有一个PowerShell脚本将一个本地文件放到S3存储桶中。但是,它失败了:
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::S3
HostName = "XXX.s3.amazonaws.com"
UserName = "AAAA"
Password = "BBB"
}
$session = New-Object WinSCP.Session
try
{
$session.SessionLogPath = "C:\Temp\Training DB\log.txt"
# Connect
$session.Open($sessionOptions)
$session.PutFiles("C:\path\Training_Employees.csv", "./Training_Employees.csv")
}
finally
{
$session.Dispose()
}
在日志中看起来我的问题是目标桶,但无法弄清楚如何指定工作:
. 2023-01-14 09:51:52.379 ssl: Shutdown state: not sent | not received.
. 2023-01-14 09:51:52.379 ssl: Sending closure.
. 2023-01-14 09:51:52.380 sess: Connection closed.
. 2023-01-14 09:51:52.380 Request ends, status 200 class 2xx, error line:
. 2023-01-14 09:51:52.380 200 OK
< 2023-01-14 09:51:52.380 <?xml version="1.0" encoding="UTF-8"?>
< 2023-01-14 09:51:52.380 <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">...</ListBucketResult>
. 2023-01-14 09:51:52.380 Request ends.
. 2023-01-14 09:51:52.380 sess: Destroying session.
* 2023-01-14 09:51:52.381 (ECommand) **Copying files to remote side failed.**
* 2023-01-14 09:51:52.381 Specify target bucket.
< 2023-01-14 09:51:52.381 Script: Copying files to remote side failed.
< 2023-01-14 09:51:52.381 Specify target bucket.
. 2023-01-14 09:51:52.382 Script: Failed
> 2023-01-14 09:51:52.445 Script: exit
. 2023-01-14 09:51:52.445 Script: Exit code: 1
1条答案
按热度按时间f1tvaqid1#
存储桶名称必须是路径的一部分。
比如
/bucket/Training_Employees.csv
,而不是./Training_Employees.csv
。请参见www.example.comhttps://winscp.net/eng/docs/faq_script_vs_gui#paths