2017-08-04 10 views
0

S3Eventによってトリガされるラムダ関数を呼び出そうとしています。私はバケットも作成しましたが、2つのイメージもバケットに追加しました。ラムダ関数の呼び出し中に実行が失敗しました

以下は、バケットの仕様です。以下は

enter image description here

私はJavaで

public String handleRequest(S3Event event, Context context) { 
    context.getLogger().log("Received event: " + event); 

    // Get the object from the event and show its content type 
    String bucket = event.getRecords().get(0).getS3().getBucket().getName(); 
    String key = event.getRecords().get(0).getS3().getObject().getKey(); 
    try { 
     S3Object response = s3.getObject(new GetObjectRequest(bucket, key)); 
     String contentType = response.getObjectMetadata().getContentType(); 
     context.getLogger().log("CONTENT TYPE: " + contentType); 
     return contentType; 
    } catch (Exception e) { 
     e.printStackTrace(); 
     context.getLogger().log(String.format(
      "Error getting object %s from bucket %s. Make sure they exist and" 
      + " your bucket is in the same region as this function.", bucket, key)); 
     throw e; 
    } 
} 

を書かれており、以下、私が

com.amazonaws.services.lambda.runtime.eventsを取得していますエラーでいる私のコードです.S3イベントが表示されない

+0

@oop大丈夫ですが、理由はありますか? – sparrowTrajon

+0

それでは、あなたはその場合にdownvoteしたいですか? – sparrowTrajon

+0

ありがとう、ありがとう:) – sparrowTrajon

答えて

1

コードが正常に表示されます。このパッケージをインポートしたことを確認してください:

com.amazonaws.services.lambda.runtime.events.S3Event

そして、あなたのクラスとインターフェイス "のRequestHandler" を実装します。これが役立つ AWS Lambda with S3 for real-time data processing

希望:問題はまだこのチュートリアルに従う続く場合は

関連する問題