Skip to content

Custom Upload component throws 400 error #14013

@Talaween

Description

@Talaween

Describe the Bug

I have followed the instructions on Payload documentation on how to provide a custom upload component at this link https://payloadcms.com/docs/custom-components/edit-view#upload:

first in media collection I added:

import type { CollectionConfig } from 'payload'

export const MyCollection: CollectionConfig = {
  // ...
  admin: {
    components: {
      edit: {
        Upload: '/path/to/MyUploadComponent',
      },
    },
  },
}

then the custom component as provided in the docs (I have to default export it which is missing in the docs)

import React from 'react'

export default function MyUploadComponent() {
  return <input type="file" />
}

generate a new import map and running, I can see the custom component. however when I select a file then hit the Save button Payload send no file uploaded notification and this error is thrown in the console:

POST http://localhost:3040/api/media?depth=0&fallback-locale=null 400 (Bad Request)

Link to the code that reproduces this issue

https://payloadcms.com/docs/custom-components/edit-view#upload

Reproduction Steps

1-create the custom component as in the documentation
2. include it in the media collecton as in the documentation
3. try to upload a new media from admin panel

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Binaries:
  Node: 22.19.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.57.0
  next: 15.5.3
  @payloadcms/db-mongodb: 3.57.0
  @payloadcms/email-nodemailer: 3.57.0
  @payloadcms/graphql: 3.57.0
  @payloadcms/next/utilities: 3.57.0
  @payloadcms/payload-cloud: 3.57.0
  @payloadcms/plugin-cloud-storage: 3.57.0
  @payloadcms/plugin-import-export: 3.57.0
  @payloadcms/plugin-stripe: 3.57.0
  @payloadcms/richtext-lexical: 3.57.0
  @payloadcms/storage-s3: 3.57.0
  @payloadcms/translations: 3.57.0
  @payloadcms/ui/shared: 3.57.0
  react: 19.1.1
  react-dom: 19.1.1
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home
  Available memory (MB): 65274
  Available CPU cores: 32

Metadata

Metadata

Assignees

Labels

area: docsImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions