【发布时间】:2019-12-02 01:00:07
【问题描述】:
我正在使用 python boto3 库通过蜂窝连接将文件从 s3 下载到 IOT 设备,这通常很慢且不稳定。
一些文件非常大(250Mb,对于这种情况来说很大)并且网络出现故障并且设备在下载时重新启动。
我想从设备重启时结束的地方继续下载。有什么办法吗?
中止的下载似乎在下载时将下载的数据保留在一个临时文件中,因此数据就在那里。
目标是节省数据传输并使下载更具弹性。
我正在使用分段上传,但不会自动恢复。
我正在做的是这样的:
s3 = boto.resource('s3')
session = boto.session.Session(region_name='eu-central-1', profile_name=profile)
s3client = session.client( 's3', config=boto.session.Config(signature_version='s3v4'))
MB = 1024 ** 2
config = TransferConfig(
multipart_threshold=10*MB,
num_download_attempts=100)
def upload():
s3client.upload_file(Filename=localfile, Bucket=bucket, Key=key, Config=config)
def download():
s3client.download_file(bucket, key, localfile, Config=config )
# upload from server...
upload()
# .... later, from IOT device
download()
【问题讨论】:
标签: python amazon-web-services amazon-s3 boto3