我正在尝试使用云功能将文件从 SFTP 服务器上传到 GCS 存储桶。但是这段代码不起作用。我能够sftp。但是当我尝试在GCS存储桶中上传文件时,它不起作用,要求是使用Python的云功能。
任何帮助将不胜感激。这是我正在尝试的示例代码。这段代码除了sftp.get("test_report.csv", bucket_destination)
. 请帮忙。
destination_bucket ="gs://test-bucket/reports"
with pysftp.Connection(host, username, password=sftp_password) as sftp:
print ("Connection successfully established ... ")
# Switch to a remote directory
sftp.cwd('/test/outgoing/')
bucket_destination = "destination_bucket"
sftp.cwd('/test/outgoing/')
if sftp.exists("test_report.csv"):
sftp.get("test_report.csv", bucket_destination)
else:
print("doesnt exist")