A serverless file upload application built with AWS services (S3, Lambda, DynamoDB).
This application allows users to:
- Upload files to an S3 bucket
- Automatically extract and store file metadata in DynamoDB
- View all uploaded file metadata through a web interface
┌─────────────┐
│ Web UI │
│ (S3 Site) │
└──────┬──────┘
│
├─────────────────┐
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ Presign │ │ Get Metadata │
│ Lambda │ │ Lambda │
└──────┬───────┘ └──────┬───────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ S3 Bucket │ │ DynamoDB │
│file-uploads │ │file-metadata │
└──────┬───────┘ └──────────────┘
│
│ (S3 Event)
▼
┌──────────────┐
│Process File │
│ Lambda │
└──────┬───────┘
│
└──────────────────┐
▼
┌──────────────┐
│ DynamoDB │
│file-metadata │
└──────────────┘
-
process_file.py - Triggered by S3 ObjectCreated events
- Extracts file metadata (name, size, type, timestamp)
- Stores metadata in DynamoDB
-
get_metadata.py - API endpoint for web UI
- Retrieves all file metadata from DynamoDB
- Returns JSON response with CORS headers
-
get_presigned_url.py - Generates S3 upload URLs
- Creates presigned POST URLs for secure file uploads
- Used by web UI to upload files directly to S3
-
S3 Buckets
file-uploads- Stores uploaded filesfile-manager-webapp- Hosts static website
-
DynamoDB Table
file-metadata- Stores file metadata- Partition key:
file_id(format: bucket/filename)
- Single-page HTML application
- Upload files via drag-and-drop or file picker
- View all file metadata in a table
- Auto-refreshes after uploads
- LocalStack running locally
- AWS CLI installed
awslocalwrapper installed- Python 3.11+
-
Navigate to the project directory:
cd aws-local -
Run the deployment script:
On Linux/Mac:
chmod +x deployment/deploy.sh ./deployment/deploy.sh
On Windows (PowerShell):
cd deployment .\deploy.ps1
-
Copy the Lambda function URLs from the output
-
Open the web application URL in your browser
-
Paste the Lambda URLs into the configuration section
-
Upload files and view their metadata!
- Open the web UI
- Configure Lambda URLs
- Select a file using the file picker
- Click "Upload"
- Wait for success message
- Click "Refresh" to see the metadata
- Go to https://app.localstack.cloud/
- Navigate to Resources > S3 to see uploaded files
- Navigate to Resources > DynamoDB to see metadata entries
- Navigate to Resources > Lambda to see function invocations
Each file entry in DynamoDB contains:
file_id: Unique identifier (bucket/filename)filename: Name of the filebucket: S3 bucket namesize_bytes: File size in bytescontent_type: MIME typefile_extension: File extensionupload_timestamp: ISO timestamp of when processeds3_last_modified: S3 last modified timestampprocessed_by: Lambda function that processed it
To remove all resources:
awslocal s3 rb s3://file-uploads --force
awslocal s3 rb s3://file-manager-webapp --force
awslocal dynamodb delete-table --table-name file-metadata
awslocal lambda delete-function --function-name process-file
awslocal lambda delete-function --function-name get-metadata
awslocal lambda delete-function --function-name get-presigned-urlDYNAMODB_TABLE: DynamoDB table name (default: file-metadata)S3_BUCKET: S3 bucket for uploads (default: file-uploads)
Test process-file Lambda:
echo '{"Records":[{"s3":{"bucket":{"name":"file-uploads"},"object":{"key":"test.txt","size":100}}}]}' | awslocal lambda invoke --function-name process-file --payload file:///dev/stdin response.jsonTest get-metadata Lambda:
awslocal lambda invoke --function-name get-metadata response.json
cat response.jsonMIT