AWS Lambda无法使用S3

时间:2016-03-02 17:26:39

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

我正在关注教程here

我正在关注Python教程但是我似乎无法让它工作,并且收到以下错误:

{"stackTrace": [
[
  "/var/task/lambda_function.py",
  20,
  "handler",
  "s3_client.download_file(bucket, key, download_path)"
],
[
  "/var/runtime/boto3/s3/inject.py",
  91,
  "download_file",
  "extra_args=ExtraArgs, callback=Callback)"
],
[
  "/var/runtime/boto3/s3/transfer.py",
  658,
  "download_file",
  "object_size = self._object_size(bucket, key, extra_args)"
],
[
  "/var/runtime/boto3/s3/transfer.py",
  724,
  "_object_size",
  "Bucket=bucket, Key=key, **extra_args)['ContentLength']"
],
[
  "/var/runtime/botocore/client.py",
  310,
  "_api_call",
  "return self._make_api_call(operation_name, kwargs)"
],
[
  "/var/runtime/botocore/client.py",
  407,
  "_make_api_call",
  "raise ClientError(parsed_response, operation_name)"
]],"errorType": "ClientError", "errorMessage": "An error occurred (404) when calling the HeadObject operation: Not Found"}

我正在尝试从名为' stylezz-images'收效甚微。这是我的代码,直接来自提供的链接:

import boto3
import os
import sys
import uuid

s3_client = boto3.client('s3')
def handler(event, context):
    for record in event['Records']:
        bucket = record['s3']['bucket']['name']
        key = record['s3']['object']['key'] 
        download_path = '/'
        upload_path = '/tmp/resized-{}'.format(key)

        print("key: " + key)
        print("bucket: " + bucket)
        print("download_path: " + download_path)
        print("upload_path: " + upload_path)

        s3_client.download_file(bucket, key, download_path)
        s3_client.upload_file(upload_path, '{}-thumbnails'.format(bucket), key)

我正在使用amazons' S3 Put'直接从lambda测试事件。任何帮助都会受到大力赞赏。

0 个答案:

没有答案