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