Skip to content

s3Storage clientUploads still sends file binary to Server Action, causing 413 error #15073

@du2333

Description

@du2333

Describe the Bug

Description

When clientUploads: true is enabled in s3Storage plugin, the initial create request (Next.js Server Action) still includes the full file binary in the multipart form data. This causes a 413 Payload Too Large error due to Next.js's default 1MB limit for Server Actions, defeating the purpose of client-side uploads.

Reproducible Code

// payload.config.ts
plugins: [
    s3Storage({
      collections: {
        media: {
          generateFileURL: ({ filename }) => `${process.env.FRONTEND_URL}/images/${filename}`,
        },
      },
      clientUploads: true,
      bucket: process.env.R2_BUCKET_NAME || '',
      config: {
        credentials: {
          accessKeyId: process.env.R2_ACCESS_KEY_ID || '',
          secretAccessKey: process.env.R2_SECRET_ACCESS_KEY || '',
        },
        region: 'auto',
        endpoint: process.env.R2_ENDPOINT || '',
      },
    }),
  ],
Image

Link to the code that reproduces this issue

https://github.com/du2333/payloadcms-reproduction-repo

Reproduction Steps

  1. Enable s3Storage with clientUploads: true.
  2. Upload a file larger than 1MB (e.g., 5MB) via the Admin UI.
  3. Observe the 413 error in the console.
  4. Check the Network tab: the /admin/collections/media/create POST request contains the file binary.

Which area(s) are affected?

plugin: storage-*

Environment Info

Binaries:
  Node: 22.15.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.25.0
Relevant Packages:
  payload: 3.69.0
  next: 15.4.10
  @payloadcms/db-postgres: 3.69.0
  @payloadcms/drizzle: 3.69.0
  @payloadcms/graphql: 3.69.0
  @payloadcms/next/utilities: 3.69.0
  @payloadcms/plugin-cloud-storage: 3.69.0
  @payloadcms/plugin-seo: 3.69.0
  @payloadcms/richtext-lexical: 3.69.0
  @payloadcms/storage-s3: 3.69.0
  @payloadcms/translations: 3.69.0
  @payloadcms/ui/shared: 3.69.0
  react: 19.2.1
  react-dom: 19.2.1
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Tue Nov 5 00:21:55 UTC 2024
  Available memory (MB): 15951
  Available CPU cores: 16

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-triagePossible bug which hasn't been reproduced yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions