Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Error on image upload

default discord avatar
kublicklast year
1

Hello


Im testing payload, when I try to upload an image, I get an error on the console I see the following:


[19:57:15] ERROR (payload): Error: EROFS: read-only file system, mkdir '/product_files'

File for this collection


 const purchasedProductFilesIds = orders.map((order) => {
    return order.products
      .map((product) => {
        if (typeof product === "string")
          return req.payload.logger.error("Search depth not sufficient");
        return typeof product.product_files === "string"
          ? product.product_files
          : product.product_files.id;
      })
      .filter(Boolean)
      .flat();
  });
  return {
    id: {
      in: [...ownProductsFilesIds, ...purchasedProductFilesIds],
    },
  };
};

export const ProductFiles: CollectionConfig = {
  slug: "product_files",
  admin: {
    hidden: ({ user }) => user?.role !== "admin",
  },
  hooks: {
    beforeChange: [addUser],
  },
  access: {
    read: yourOwnPurchased,
    update: ({ req }) => req.user?.role === "admin",
    delete: ({ req }) => req.user?.role === "admin",
  },
  upload: {
    staticURL: "/product_files",
    staticDir: "/product_files",
    mimeTypes: ["image/*", "font/*", "application/postcript"],
  },
  fields: [
    {
      name: "user",
      type: "relationship",
      relationTo: "users",
      admin: {
        condition: () => false,
      },
      required: true,
      hasMany: false,
    },
  ],
};


ok the workaround now its to launch the server as sudo user in linux, how would be the proper way to launch it ?


on Mac I still get the error



ok managed to find the issue I mistakenly added to the staticURL an /

  • default discord avatar
    jitesh2574last year

    Hi guys,


    I’m getting error there was a problem while uploading a file



    Any solve for this error

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.