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?

asked 5 years ago268 views
1 Answer
0
Accepted Answer

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)
answered 5 years ago
profile picture
EXPERT
reviewed 20 hours ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions