我有一个S3存储桶,mybucket并且想要在将新文件复制到该存储桶中时执行某些操作。对于通知,我想使用SQS队列notifiqueue,因为我的目标是使用Laravel
由于我在中创建了基础架构CloudFormation,因此资源的创建是这样的:
NotificationQueue:
Type: AWS::SQS::Queue
Properties:
VisibilityTimeout: 120
QueueName: 'NotificationQueue'
DataGateBucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: BucketOwnerFullControl
BucketName: 'mybucket'
NotificationConfiguration:
QueueConfigurations:
- Event: 's3:ObjectCreated:*'
Queue: !GetAtt NotificationQueue.Arn
每次将新文件保存在存储桶中时,S3都会在SQS中自动创建一个通知。
可悲的是,有效负载的格式与Laravel标准作业有效负载不兼容,并且如果我在上运行辅助进程,则会NotificationQueue收到此错误:
local.ERROR: Undefined index: job {"exception":"[object] (ErrorException(code: 0): Undefined index: job at .../vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:273)
为了提供更完整的指示,这是我在通知中得到的内容(将JSON转换为PHP数组之后)
array:1 [
"Records" => array:1 [
0 => array:9 [
"eventVersion" => "2.1"
"eventSource" => "aws:s3"
"awsRegion" => "eu-central-1"
"eventTime" => "2019-04-23T17:02:41.308Z"
"eventName" => "ObjectCreated:Put"
"userIdentity" => array:1 [
"principalId" => "AWS:XXXXXXXXXXXXXXXXXX"
]
"requestParameters" => array:1 [
"sourceIPAddress" => "217.64.198.7"
]
"responseElements" => array:2 [
"x-amz-request-id" => "602CE18B8DE0BE5C"
"x-amz-id-2" => "wA/A3Jl2XpoxBWJEgQzy11s6O28Cz9Wc6pVi6Ho1vnIrOjqsWkGozlUmqRdpYAfub0MqdF8d/YI="
]
"s3" => array:4 [
"s3SchemaVersion" => "1.0"
"configurationId" => "0d4eaa75-5730-495e-b6d4-368bf3690f30"
"bucket" => array:3 [
"name" => "mybucket"
"ownerIdentity" => array:1 [
"principalId" => "XXXXXXXXXXXXXXXXXX"
]
使用Laravel访问通知的最有效/正确/正确的方法是哪种,以便我可以触发其他选项来响应文件上传?
米琪卡哇伊