Receive notification when download is complete in the Amazon S3 Bucket

Is there a way I can be notified when a download is complete in S3 Bucket? The requirement is that I need to provide a link to users after the video has finished loading in the bucket. By default, now I provide a link after 30 minutes of the start of the video, regardless of whether the video takes 5 minutes to download or 40 minutes. So, is there any way like any API that provides information on loading completion?

+5
source share
3 answers

There is no direct method that could tell if the download is complete or not in the S3 bucket. You can do the simple thing that I followed after a lot of research, and it works correctly.

Follow this link and read the file size every 30 seconds or so according to your requirement, when the file size has not changed by two, simultaneous reading once again checks the size for the guarantor, because this may be due to network congestion, the size of which may not be changed for two simultaneous readings.

0
source

Notifications can trigger on Amazon S3 when any of the following events occur:

  • s3:ObjectCreated:*
  • s3:ObjectCreated:Put
  • s3:ObjectCreated:Post
  • s3:ObjectCreated:Copy
  • s3:ObjectCreated:CompleteMultipartUpload
  • s3:ObjectRemoved:*
  • s3:ObjectRemoved:Delete
  • s3:ObjectRemoved:DeleteMarkerCreated
  • s3:ReducedRedundancyLostObject

Notifications can be sent through three destinations:

  • Amazon Simple Notification Service (SNS) , which in turn can send notifications by email, HTTP / S endpoint, SMS, mobile push notification
  • Amazon Simple Queuing Service (SQS)
  • Amazon Lambda (not yet available in all regions)

See: Setting up Amazon S3 event notifications

The most suitable choice depends on your preference for programming and how your application is written:

  • Use SNS to navigate to the HTTP endpoint to invoke some code in your application.
  • Write a code to periodically check the SQS queue
  • Write a lambda function in Node.js or Java

After launching, your code will then need to determine who uploaded the video, get their user data, and then send them an email notification. This would be easiest if you control the key (file name) of the loaded object, as this will help identify the user for notification.

+6
source

You can use Amazon Lambda to send a message to Amazon SNS (or notify you in any other way) when the file is uploaded to S3.

0
source

All Articles