0
我想調用一個由S3Event觸發的lambda函數,我也創建了一個存儲桶,並且還將兩個圖像添加到存儲桶中。執行失敗,同時調用lambda函數
以下是桶的規格。
下面是我的代碼,我已經寫在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錯誤.S3Event不存在
@oop它沒關係,但我可以有理由嗎? – sparrowTrajon
好的,所以你想downvote在這種情況下? – sparrowTrajon
好的,謝謝:) – sparrowTrajon