简体   繁体   中英

Capture the S3 file download start and end times and other details

I want to expose an API (preferably using AWS API gateway/ Lambda/Go) to the users.

Using this API, the users can download a binary file from S3 bucket.

I want to capture the metrics like, which user has started download of the file, the time at which the file download had started and finished.

I want to record these timestamps in DynamoDB.

S3 has support for Events for creating/modifying/deleting files, so I can write a lambda function for these events.

But S3 doesn't seems to have support for read actions ( eg download a file)

I am thinking to write a Lambda function, which will be invoked when the user calls the API to download the file. In the lambda, I want to record the timestamp, read the file into a buffer, encode it and then send it as as base64 encoded response to the client.

Let me know if there is any better alternative approach.

use Amazon S3 Server Access Logging

don't use DynamoDB, if you need to query the logs in the target bucket setup Spectrum to query the logs which are also in S3

Maybe you can use S3 Access Logs ?

And configure event based on new records in log bucket. However, this logs will not tell you if user has finished download or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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