amazon web services - AWS Lambda S3Event deserialization -
has implemented java based request handler s3 events?
my class:
package example; import com.amazonaws.services.lambda.runtime.context; import com.amazonaws.services.lambda.runtime.requesthandler; import com.amazonaws.services.s3.model.s3event; public class hello implements requesthandler<s3event, string> { public string handlerequest(s3event event, context context) { return "success"; } }
error message:
an error occurred during json parsing: java.lang.runtimeexception java.lang.runtimeexception: error occurred during json parsing caused by: java.io.uncheckedioexception: com.fasterxml.jackson.databind.jsonmappingexception: can not deserialize instance of com.amazonaws.services.s3.model.s3event out of start_object token @ [source: lambdainternal.util.nativememoryasinputstream@6108b2d7; line: 1, column: 1] caused by: com.fasterxml.jackson.databind.jsonmappingexception: can not deserialize instance of com.amazonaws.services.s3.model.s3event out of start_object token @ [source: lambdainternal.util.nativememoryasinputstream@6108b2d7; line: 1, column: 1] @ com.fasterxml.jackson.databind.jsonmappingexception.from(jsonmappingexception.java:148) @ com.fasterxml.jackson.databind.deserializationcontext.mappingexception(deserializationcontext.java:835) @ com.fasterxml.jackson.databind.deserializationcontext.mappingexception(deserializationcontext.java:831) @ com.fasterxml.jackson.databind.deser.std.enumdeserializer._deserializeother(enumdeserializer.java:137) @ com.fasterxml.jackson.databind.deser.std.enumdeserializer.deserialize(enumdeserializer.java:89) @ com.fasterxml.jackson.databind.deser.std.enumdeserializer.deserialize(enumdeserializer.java:18) @ com.fasterxml.jackson.databind.objectreader._bindandclose(objectreader.java:1441) @ com.fasterxml.jackson.databind.objectreader.readvalue(objectreader.java:1047)
the solution take s3eventnotification. wish covered in aws documentation. lambda concept there not documentation or examples out there.
public void mergeglau(s3eventnotification notification, context context) { try { (s3eventnotificationrecord record : notification.getrecords()) { system.out.println(record.geteventsource()); system.out.println(record.geteventname()); system.out.println(record.gets3().getbucket().getname()); system.out.println(record.gets3().getobject().getkey()); } } catch (exception e) { e.printstacktrace(); } }
Comments
Post a Comment