payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
29.26k stars 1.81k forks source link

Upload multiple files using REST API #9737

Open gor3a opened 8 hours ago

gor3a commented 8 hours ago

Describe the Bug

I tried to upload multiple files using REST API that mentioned in docs Upload Files, the single file works well

Image

But I got error

[16:29:04] ERROR: Cannot read properties of undefined (reading 'includes')
    err: {
      "type": "TypeError",
      "message": "Cannot read properties of undefined (reading 'includes')",
      "stack":
          TypeError: Cannot read properties of undefined (reading 'includes')
              at generateFileData (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.2.2_graphql@16.8.1_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241020_react_qv6xnetjprece3gvrppmkpo4cq/node_modules/payload/dist/uploads/generateFileData.js:163:27)
              at createOperation (webpack-internal:///(rsc)/./node_modules/.pnpm/payload@3.2.2_graphql@16.8.1_monaco-editor@0.52.0_react-dom@19.0.0-rc-65a56d0e-20241020_react_qv6xnetjprece3gvrppmkpo4cq/node_modules/payload/dist/collections/operations/create.js:80:145)
              at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
              at async Object.create (webpack-internal:///(rsc)/./node_modules/.pnpm/@payloadcms+next@3.2.2_graphql@16.8.1_monaco-editor@0.52.0_next@15.0.0_react-dom@19.0.0-rc-65_thuhuskbxwhezen25znrjkqmke/node_modules/@payloadcms/next/dist/routes/rest/collections/create.js:29:15)
              at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@payloadcms+next@3.2.2_graphql@16.8.1_monaco-editor@0.52.0_next@15.0.0_react-dom@19.0.0-rc-65_thuhuskbxwhezen25znrjkqmke/node_modules/@payloadcms/next/dist/routes/rest/index.js:487:19)

Link to the code that reproduces this issue

pnpx create-payload-app@latest -t blank

Reproduction Steps

  1. Create a blank project with media collection
  2. Enable bulkUpload in upload config
  3. using /api/media endpoint and passing file param with multiple file using postman or any alternative with request type form-data

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

area: core

Environment Info

Payload: 3.2.2
Next: 15.0.0
Nodejs: 20.18.1
github-actions[bot] commented 8 hours ago

Please add a reproduction in order for us to be able to investigate.

Depending on the quality of reproduction steps, this issue may be closed if no reproduction is provided.

Why was this issue marked with the invalid-reproduction label?

To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository created with create-payload-app@beta -t blank or a forked/branched version of this repository with tests added (more info in the reproduction-guide).

To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.

Please test your reproduction against the latest version of Payload to make sure your issue has not already been fixed.

I added a link, why was it still marked?

Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.

Useful Resources