Skip to content

Instantly share code, notes, and snippets.

@saswata-dutta
Created April 22, 2023 17:27
Show Gist options
  • Save saswata-dutta/0390312e505f94dc44c12550514f861b to your computer and use it in GitHub Desktop.
Save saswata-dutta/0390312e505f94dc44c12550514f861b to your computer and use it in GitHub Desktop.
import boto3
import json
s3_client = boto3.client('s3')
def lambda_handler(event, context):
# Extract the S3 bucket and object key from the event
bucket = event['Records'][0]['s3']['bucket']['name']
key = event['Records'][0]['s3']['object']['key']
# Perform desired actions on the uploaded file
process_uploaded_file(bucket, key)
return {
"statusCode": 200,
"body": json.dumps({
"message": f"File {key} in bucket {bucket} processed successfully"
})
}
def process_uploaded_file(bucket, key):
# Implement your file processing logic here
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment