Could I know the event upload file on aws s3 automatically?

0

I'm using Node JS to subscribe SNS on AWS and SQS to handle queues . How do I know if a file has been uploaded to S3 then sent the message to node js automatically via SNS?

질문됨 5년 전292회 조회
1개 답변
0
수락된 답변

You can do that send notification using SNS when any file uploaded to s3

https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

require 'aws-sdk-s3'  # v2: require 'aws-sdk'

req = {}
req[:bucket] = bucket_name

events = ['s3:ObjectCreated:*']

notification_configuration = {}

# Add function
lc = {}

lc[:lambda_function_arn] = 'my-function-arn'
lc[:events] = events
lambda_configurations = []
lambda_configurations << lc

notification_configuration[:lambda_function_configurations] = lambda_configurations

# Add queue
qc = {}

qc[:queue_arn] = 'my-topic-arn'
qc[:events] = events
queue_configurations = []
queue_configurations << qc

notification_configuration[:queue_configurations] = queue_configurations

# Add topic
tc = {}

tc[:topic_arn] = 'my-topic-arn'
tc[:events] = events
topic_configurations = []
topic_configurations << tc

notification_configuration[:topic_configurations] = topic_configurations

req[:notification_configuration] = notification_configuration

req[:use_accelerate_endpoint] = false

s3 = Aws::S3::Client.new(region: 'us-west-2')

s3.put_bucket_notification_configuration(req)
답변함 5년 전
profile picture
전문가
검토됨 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠