简体   繁体   English

S3 Presigned Url Callback

[英]S3 Presigned Url Callback

Is there a way to know if someone has uploaded something to generated public presigned url of S3? 有没有办法知道是否有人上传了一些东西来生成S3的公共预约网址? Like a callback that will trigger my servlet. 就像一个会触发我的servlet的回调。

For example: 例如:

I created a presigned url from this docs 我从这个文档中创建了一个预先签名的URL

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. 然后,我将url发送给某人,如果有人将某些内容上传到该url ,则会使用上传文件中的数据调用http://example.com/upload

You can use S3 event notifications to generate a notification. 您可以使用S3事件通知生成通知。 Look at the ObjectCreated event. 查看ObjectCreated事件。 The notifications can be filtered by the S3 prefix. 可以通过S3前缀过滤通知。 (There are samples in the AWS documentation on the linked page.) (链接页面上的AWS文档中有样本。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM