#Duplicating a file results to a resource not found error

11 messages · Page 1 of 1 (latest)

lethal pike
warm oriole
#

@lethal pike interesting, I have not been able to reproduce this - could you share your collection config here?

lethal pike
#

Alright will. Send u when I get back

lethal pike
#
import { CollectionConfig } from "payload/types";
import { isAdminOrHasSiteAccess } from "../access/isAdminOrHasSiteAccess";
import { isLoggedIn } from "../access/isLoggedIn";

export const Files: CollectionConfig = {
  slug: "files",
  upload: true,
  admin: {
    group: "Other",
  },
  access: {
    // Anyone logged in can create
    create: isLoggedIn,
    // Only admins or editors with site access can update
    update: isAdminOrHasSiteAccess(),
    // Only admins or editors with site access can read
    read: () => true,
    // Only admins or editors with site access can delete
    delete: isAdminOrHasSiteAccess(),
  },
  fields: [
    {
      name: "alt",
      type: "text",
      required: true,
    },
    {
      name: "site",
      type: "relationship",
      relationTo: "sites",
      required: true,
      // If user is not admin, set the site by default
      // to the first site that they have access to
      defaultValue: ({ user }) => {
        if (!user.roles.includes("admin") && user.sites?.[0]) {
          return user.sites[0];
        }
      },
    },
  ],
};

warm oriole
#

Hey @lethal pike - sorry for the delay here, I was able to duplicate a file successfully with the collection config you shared so I'm not sure the root of this issue. Are you still experiencing this?

lethal pike
#

Hello no worries, thanks for the reply