This is a Next.js project bootstrapped with create-next-app.
First, clone the repo https://github.com/Ajay01103/NextJS-14-S3-Upload
npm install
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev- Configure Bucket Policy in the bucket Permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": "arn:aws:s3:::your-bucket/*"
}
]
}
- Configure CORS Policy in Bucket Permissions
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"PUT",
"GET",
"DELETE"
],
"AllowedOrigins": [
"http://localhost:3000"
],
"ExposeHeaders": [],
"MaxAgeSeconds": 3000
}
]
- Keep the Block Public Access Disabled in very first stage of creating a s3 bucket
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.