小编tra*_*ant的帖子

从 s3 读取时出现溢出错误 - 有符号整数大于最大值

使用以下代码将大文件从 S3 (>5GB) 读取到 lambda 中:

import json
import boto3

s3 = boto3.client('s3')

def lambda_handler(event, context):
    
    response = s3.get_object(
        Bucket="my-bucket",
        Key="my-key"
    )
    
    text_bytes = response['Body'].read()

    ...
    
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

"errorMessage": "signed integer is greater than maximum"
"errorType": "OverflowError"
"stackTrace": [
    "  File \"/var/task/lambda_function.py\", line 13, in lambda_handler\n    text_bytes = response['Body'].read()\n"
    "  File \"/var/runtime/botocore/response.py\", line 77, in read\n    chunk = self._raw_stream.read(amt)\n"
    "  File \"/var/runtime/urllib3/response.py\", line 515, in read\n    data = self._fp.read() if not fp_closed …
Run Code Online (Sandbox Code Playgroud)

python amazon-s3 aws-lambda

5
推荐指数
1
解决办法
6977
查看次数

标签 统计

amazon-s3 ×1

aws-lambda ×1

python ×1