This project aims to simplify the process of uploading optimized images to a static site. It resizes images for different devices (tablet, mobile, PC) and converts them to WebP format before uploading them to S3. The usual manual process is time-consuming, so this tool was created to handle it all at once.
Make sure to install Yarn before starting.
The project is organized using Yarn workspaces
Make sure you have Yarn installed on your machine.
npm install -g yarn
Generate an Access Key and Secret Key from AWS IAM.
Create a .env
file inside the presigned-url workspace
# presigned-url/.env
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
Start the server to generate presigned URLs for S3
yarn presigned-url start:server
This will run a server on localhost:3000
using the provided keys.
Start the image converter site
yarn web dev
Fill out the fields as required and click the upload button
Ensure your S3 bucket has the following permissions
Allow s3:GetObject
s3:PutObject
actions.
// example
{
"Version": "VERSION",
"Id": "POLICYEXAMPLE",
"Statement": [
{
"Sid": "SIDEXAMPLE",
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::YOUR_ARN/*"
}
]
}
Configure CORS to allow requests from your local setup
// example
[
{
"AllowedHeaders": ["*"],
"AllowedMethods": ["PUT", "POST"],
"AllowedOrigins": ["http://localhost:5173"],
"ExposeHeaders": []
}
]