How can I change the upload.staticDir dynamically based on certain conditions, like the media_type? For example, I need to change the staticDir path based on whether the media is a profile_picture, project_image, or icon. How can I achieve this in PayloadCMS 3?
import type { CollectionConfig } from "payload";
export const Media: CollectionConfig = {
slug: "media",
access: {
read: () => true,
},
fields: [
{
name: "media_type",
type: "select",
required: true,
options: [
{ label: "Profile Picture", value: "profile_picture" },
{ label: "Project Image", value: "project_image" },
{ label: "Icon", value: "icon" },
],
},
],
upload: {
staticDir: "", // Need to set this conditionally
mimeTypes: ["image/*"],
},
};
How can I set the staticDir to different directories based on the selected media_type (e.g., profile-pictures/, project-images/, or icons/)?