Storage
Learn how to set up and use Amazon S3 for file storage and media handling
Dirstarter uses Amazon S3 for file storage and media handling, providing a reliable and scalable solution for storing images, screenshots, and other media files.
Amazon S3
Amazon S3 is a cloud storage service that offers:
- High availability and durability
- Global distribution
- Pay-per-use pricing
- Built-in CDN integration
- Fine-grained access control
- Versioning and lifecycle management
Setup
Create an AWS account
Go to aws.amazon.com and create an account.
Create a new S3 bucket:
Navigate to the S3 service
Create a new bucket with the following options:
- Pick globally unique bucket name (e.g.,
your-project-name
) - Select a region close to your target audience
- Disable "Block all public access" (very important if you want files to be publicly accessible)
- Bucket versioning: Optional, enables version control for files
Click "Create bucket"
Add a bucket policy to allow public access. Go to the Permissions tab and add the following policy:
Create an IAM user with S3 access:
Navigate to the IAM service
Create a new policy:
- Select S3 as the service
- Add permissions:
GetObject
,PutObject
,DeleteObject
,ListBucket
- Limit the resources to your bucket:
arn:aws:s3:::your-project-name/*
Example policy:
Create a new IAM user:
- Select "Programmatic access"
- Attach the policy you created
Save the Access Key ID and Secret Access Key
S3-Compatible Alternatives
While Amazon S3 is our recommended choice, you can use any S3-compatible storage service. Here are some popular alternatives:
When using a non-AWS S3 provider, make sure to update the endpoints in lib/media.ts
to the correct endpoint URL.
Media Handling
The boilerplate includes a comprehensive media handling system in lib/media.ts
:
Last updated on