【发布时间】:2019-10-15 11:48:31
【问题描述】:
在 AWS Lambda 上从 S3 读取文件时,我得到 IncompleteReadError。当我在本地尝试时,它工作得很好。这仅在 Python3.6 上发生并且在 Python3.7 上运行良好 - 但是我需要使用 Python3.6。我也尝试使用资源而不是客户端,但得到了同样的错误
Traceback (most recent call last):
File "/var/task/function.py", line 141, in handler
i = d.read()
File "/var/runtime/botocore/response.py", line 82, in read
self._verify_content_length()
File "/var/runtime/botocore/response.py", line 134, in _verify_content_length
expected_bytes=int(self._content_length))
botocore.exceptions.IncompleteReadError: 0 read, but total bytes expected is 36678.
失败的代码区域在这里:
client = boto3.client('s3')
get_json_file = client.get_object(
Bucket=os.environ['S3_BUCKET'],
Key="{0}".format(file_name),
)
d = get_json_file.get('Body')
i = d.read()
data = json.loads(i)
【问题讨论】:
标签: python-3.x amazon-web-services amazon-s3 aws-lambda boto3