Next.js Discord

Discord Forum

Uploading multiple images using Server Actions with Sharp Prisma ORM and AWS S3 bucket.

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
When I upload one image, it works, but when I upload multiple images, the console shows "Function Payload Too Large."

The Purpose of Sharp is to reduce file size and convert it into webp. Then, AWS S3 returns a URL and saves it to my database

What are some alternative solutions for this problem?

3 Replies

The error is because your server doesn't seem to support a large file size. You have a few options:
1. Increase the file size limit of the server [Server actions config](https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit) | [API routes config](https://nextjs.org/docs/messages/api-routes-response-size-limit)
2. Upload the files one by one instead of sending all of them at once.
3. Do the processing client-side and upload them from the client itself
Masai LionOP
@Riday 💙 Thank you!🙂
@Riday 💙 I will try to set bodySizeLimit to '100mb'