[英]S3ToSFTP: Move multiple files from same S3 key to SFTP path
要求:將多個文件從同一個 S3 密鑰移動到 SFTP
以下是部分代碼,我能夠實現將一個文件移動到 SFTP 位置。 如果 s3_key 位置有超過 1 個文件示例,如下所示,我需要從 /path/output 獲取兩個文件到 SFTP 位置
/path/output/abc.csv
/path/output/def.csv
試過:但兩個文件都沒有發布
Tried passing s3_key as '/path/output/*.csv'
代碼
with sftp.open(sftp_path + key_name, 'wb') as f:
s3_client.download_fileobj(s3_bucket,s3_key, f)
除了將文件下載到本地文件之外:
client.download_file(bucket, k, dest_pathname)
...您將 stream 將它們發送到 SFTP:
with sftp.open(sftp_path + file.get('Key'), 'wb', 32768) as f:
client.download_file(bucket, k, f)
請注意,這個簡單的更改不處理“子文件夾”。
對於32768
參數的目的,請參閱寫入使用 pysftp“open”方法打開的 SFTP 服務器上的文件很慢。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.