#Unable to Save a Portfolio Item

19 messages · Page 1 of 1 (latest)

steady ferry
#

Hi. I've setup a Portfolio collection and added it to the Payload config.
I'm not receiving an error in VSCode. When I create a portfolio item and click save I receive a message 'No files were uploaded.' and console error message:
POST http://localhost:3000/api/portfolio?locale=en&depth=0&fallback-locale=null 400 (Bad Request)

#

Portfolio.tsx


const Portfolio: CollectionConfig = {
  slug: 'portfolio',
  access: {
    create: (): boolean => true, // Everyone can create Portfolio items
    read: (): boolean => true, // Everyone can read Portfolio items
    update: (): boolean => true, // Everyone can update Portfolio items
    delete: (): boolean => true, // Everyone can delete Portfolio items
  },

  fields: [
    {
      name: 'title',
      label: 'Title',
      type: 'text',
      required: true,
    },
    {
      name: 'subtitle',
      label: 'Venue Title',
      type: 'text',
      required: true,
    },
    {
      name: 'backgroundImage',
      type: 'upload',
      relationTo: 'media',
      required: true,
    },
    {
      name: 'alt',
      label: 'Alt Text',
      type: 'text',
      required: true,
    },
  ],
};

export default Portfolio;
#

Any ideas?

(Any other suggestions to improve this code will be appreciated)

steady ferry
#

I'm using Nextjs

serene tulip
#

Are you using the Admin UI to add the Portfolio Item or are you trying to do it from your frontend with an http post request? If it's the latter, are you able to do it from the Admin UI?

steady ferry
#

AdminUI

serene tulip
#

Hmm, are you able to save other documents in other collections?

steady ferry
#

Yes the other fields work

#

collections*

#

I'm getting this error when I start the Payload server in Nextjs - ``` yarn run v1.22.19
$ ts-node server.ts
[20:56:14] INFO (payload): Connected to Mongo server successfully!
[20:56:14] INFO (payload): Starting Payload...
info - Loaded env from C:\git\2160\2160-Lodge-Bukela-2.env
webpack built ab43f4191f7a65cf1eb2 in 15364ms
webpack compiled successfully
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: No serializer registered for ConcatSource
<w> while serializing webpack/lib/util/registerExternalSerializer.webpack-sources/ConcatSource -> Array { 2 items } -> ConcatSource

serene tulip
#

What if you try starting it with the default yarn run dev command?

steady ferry
#

Chatgpt: "It looks like there is an issue with serializing the ConcatSource object, which is causing the caching to fail. This warning message should not cause any major issues, but it might slow down your Webpack build time if the cache is not working properly.

One way to resolve this issue is to clear the Webpack cache by running yarn cache clean. You can also try updating your Webpack version or any dependencies related to Webpack to see if that fixes the issue."

#

So that shouldn't be part of the error

amber narwhal
#

Portfolio.tsx should be Portfolio.ts, shouldn't it?

serene tulip
#

Oh, yeah, I was wondering why it was tsx as well

steady ferry
#

It's working now, not sure what the fix was as my Portfolio file was named .ts the entire time. Thanks for the help.

mental wyvern
#

i get this as well. i am using the "upload" configuration on the collection. when save the collection i get this error , removing it stops the error. i wonder id there is an option to not forcing uploading an image. when i scrapping some data locally, i would like to create the collection sometimes with the images and sometimes without them.