I was able to setup the cloudStorage plugin with the s3 adapter, and was wondering if it was possible to have multiple upload fields per collection. For example if i have a Candy collection. Could i upload multiple files, one for like "logo" the other for "nutrition facts"? I'm new to Payload, so please humble me
A common way of doing this is to have a two collections: one for your uploads, and another for the documents that use them.
So you could have a
Media
collection for uploads, and a
Candy
collection for the candies, and then add fields on the
Candy
collection that relate to your
Media
collection.
Your
Candy
collection would look something like this:
export const Candy = {
slug: "candy",
fields: [
// Other fields here...
{
name: 'images',
type: 'array',
label: 'Images',
fields: [
{
name: "candyImage",
label: "Image",
type: "upload",
relationTo: "media",
},
],
},
],
};
that is so awesome! ok, so then if I were to have another collection like
Store
where I want to also upload files is the best practice to use the same
Media
collection?
Yup, you can totally do it that way. Most people just use one, but you can also create multiple upload-enabled collections.
If for whatever reason you wanted to do more than one, you would just want to make sure you add it to the cloudStorage plugin config.
you've been so helpful thank you!
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.