[英]downloading files from s3 bucket in amazon ec2 to local drive in windows 7
我正在尝试通过boto3和python3脚本从Amazon ec2的s3存储桶中下载所有示例文件到本地硬盘。 这是脚本。
#downloading files from s3
import boto3
import sys
import os
import argparse
import threading
from botocore.client import Config
instance_id = "i-03e7f6391a0f523ee"
action = 'ON'
ec2 = boto3.client('ec2')
s3=boto3.resource('s3')
for bucket in s3.buckets.all():
print(bucket.name)
my_bucket=s3.Bucket('tkbucket32')
print("listing all files in bucket")
for s3_file in my_bucket.objects.all():
print(s3_file.key)
s3.meta.client.download_file('tkbucket32', 'hello.txt', '/tmp/hello.txt')
当前存储桶中有以下文件
hello.txt myhomepage.html
现在我希望将它们下载到
D:\folder1\folder2\folder3
我正在Windows 7中运行脚本。我的问题是这一行
s3.meta.client.download_file('tkbucket32', 'hello.txt', '/tmp/hello.txt')
在哪里我要下载这些文件的本地硬盘上指定路径?
更改此行:
s3.meta.client.download_file('tkbucket32', 'hello.txt', '/tmp/hello.txt')
至:
s3.meta.client.download_file('tkbucket32', 'hello.txt', 'D:\\folder1\\folder2\\folder3\\hello.txt')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.