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?

gefragt vor 5 Jahren303 Aufrufe
1 Antwort
0
Akzeptierte Antwort

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)
beantwortet vor 5 Jahren
profile picture
EXPERTE
überprüft vor 2 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen