Hi,
I encountered an error when file is not written to the filesystem when it is uploaded. However, this happens only in production. In development, everything works. The config for media collection is pretty standard.
What's even more strange is that no error is encountered and the image is being correctly shown in the media list. I do not know from where, because it is not written do the disk. Maybe some cache?
Thanks for any help
import path from "path";
import type { CollectionConfig } from "payload/types";
export const Media: CollectionConfig = {
slug: "media",
upload: {
staticDir: path.resolve(__dirname, "..", "..", "files", "media"),
},
fields: [
{
name: "name",
type: "text",
},
],
};
Sorry, I have found the bug in the meanwhile. The problem was that in development, the media files were saved to /files/media
, like shown in the example.
However, when compiled to production, the project gets compiled to dist
folder, so in the end, the Payload saves media files to /dist/files/media
. Silly error, but took a while to spot it.
Thanks!
I encountered an error when file is not written to the filesystem when it is uploaded.
What is the error exactly?
Sorry, I have found the bug in the meanwhile. The problem was that in development, the media files were saved to /files/media
, like shown in the example.
However, when compiled to production, the project gets compiled to dist
folder, so in the end, the Payload saves media files to /dist/files/media
. Silly error, but took a while to spot it.
Thanks!
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.