Question in title says it all.
currently here's my config :
plugins: [
s3Storage({
collections: {
fichiers: {
disableLocalStorage: true,
disablePayloadAccessControl: true,
prefix: "media/files",
generateFileURL: async (doc) => {
console.log("logging doc", doc)
return `${process.env.R2_ENDPOINT}/${process.env.R2_BUCKET_NAME}/${doc.prefix}/${doc.filename}`
},
}
},
bucket: process.env.R2_BUCKET_NAME,
config: {
endpoint: process.env.R2_ENDPOINT,
credentials: {
accessKeyId: process.env.R2_ACCESS_KEY_ID,
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
},
region: process.env.R2_REGION,
},
}),
],
when logging doc, I can see a "fields" array, but it seems populated with the field's config rather than field's content.
I tried using something like
hooks: {
afterRead: [
async ({doc}) => {
return {
...doc,
prefix: `${doc.prefix}/${doc.linkedTournage}/${doc.filename}`
}
}
]
},
or
hooks: {
afterRead: [
async ({doc}) => {
return {
...doc,
filename: `${doc.linkedTournage}/${doc.filename}`
}
}
]
},
but it didn't have an effect on the generated path.
linkedTournage is a relationship but when doc is logged in that hook I can see the id as string which is expected.
i can see the id being added to the title of the doc but I want the path to change on my R2. any suggestions ?
maybe I'm using the wrong hook ?
Thanks in advance