gpt4 book ai didi

python - 使用 Python 在 Lambda 中处理 S3 桶触发事件

转载 作者:太空狗 更新时间:2023-10-29 23:57:18 25 4
gpt4 key购买 nike

AWS Lambda 处理程序的签名为

def lambda_handler(event, context):

但是,当触发器是接收放置的 S3 存储桶时,我找不到任何关于事件结构的文档

我认为它可能在 s3 控制台中定义,但在那里找不到。

有人有线索吗?

最佳答案

从 S3 到 Lambda 函数的事件将采用 json 格式,如下所示,

{  
"Records":[
{
"eventVersion":"2.0",
"eventSource":"aws:s3",
"awsRegion":"us-east-1",
"eventTime":The time, in ISO-8601 format, for example, 1970-01-01T00:00:00.000Z, when S3 finished processing the request,
"eventName":"event-type",
"userIdentity":{
"principalId":"Amazon-customer-ID-of-the-user-who-caused-the-event"
},
"requestParameters":{
"sourceIPAddress":"ip-address-where-request-came-from"
},
"responseElements":{
"x-amz-request-id":"Amazon S3 generated request ID",
"x-amz-id-2":"Amazon S3 host that processed the request"
},
"s3":{
"s3SchemaVersion":"1.0",
"configurationId":"ID found in the bucket notification configuration",
"bucket":{
"name":"bucket-name",
"ownerIdentity":{
"principalId":"Amazon-customer-ID-of-the-bucket-owner"
},
"arn":"bucket-ARN"
},
"object":{
"key":"object-key",
"size":object-size,
"eTag":"object eTag",
"versionId":"object version if bucket is versioning-enabled, otherwise null",
"sequencer": "a string representation of a hexadecimal value used to determine event sequence,
only used with PUTs and DELETEs"
}
}
},
{
// Additional events
}
]
}

这是可以指导您的 aws 文档的链接。 http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html

关于python - 使用 Python 在 Lambda 中处理 S3 桶触发事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44317216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com