S3 Presigned Url Callback

Question!

Is there a way to know if someone has uploaded something to generated public presigned url of S3? Like a callback that will trigger my servlet.

For example:

I created a presigned url from this docs

AmazonS3 s3Client = new AmazonS3Client(new ProfileCredentialsProvider()); 

java.util.Date expiration = new java.util.Date();
long msec = expiration.getTime();
msec += 1000 * 60 * 60; // Add 1 hour.
expiration.setTime(msec);

GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, objectKey);
generatePresignedUrlRequest.setMethod(HttpMethod.PUT); 
generatePresignedUrlRequest.setExpiration(expiration);

URL url = s3client.generatePresignedUrl(generatePresignedUrlRequest); 

// Use the pre-signed URL to upload an object.

then, I give the url to someone and if that someone upload something to that url, the http://example.com/upload will be invoked with data from uploaded file.



Answers

You can use S3 event notifications to generate a notification. Look at the ObjectCreated event. The notifications can be filtered by the S3 prefix. (There are samples in the AWS documentation on the linked page.)

By : jbird


This video can help you solving your question :)
By: admin