Python:AWS Lambda S3从URL SSL验证上传图像失败

时间:2018-10-04 09:45:33

标签: python amazon-web-services amazon-s3 aws-lambda

我有这样的功能:

def save_image(url_image, filename):
    session = boto3.Session(aws_access_key_id=access_key,
              aws_secret_access_key=secret_access,
              region_name='ap-southeast-1')
    bucketName = "bucket"
    req_for_image = requests.get(url_image, stream=True)
    file_object_from_req = req_for_image.raw
    # req_data = file_object_from_req.read()
    s3 = session.resource('s3')
    s3.Bucket(bucketName).upload_fileobj(file_object_from_req, 
    filename)

,当我在本地运行时它可以工作。但是,当我尝试将函数上传到lamda时,出现错误:

    {
      "errorMessage": "SSL validation failed for https://s3.ap-southeast- 
       1.amazonaws.com/bucket/filename.jpg [Errno 2] No such file or 
    directory",
     "errorType": "SSLError",
     "stackTrace": [
     [
       "/var/task/main.py",
       63,
       "lambda_handler",
        "return main_func()"
etc.

知道为什么会这样吗?

0 个答案:

没有答案