Hey
@610189286809272348,
Yes, I believe you're looking for this:
https://payloadcms.com/docs/upload/storage-adapters#payload-access-controlBy setting
disablePayloadAccessControl: trueyou bypass Payload
Is it possible to configure that to use access control for draft content, but bypass for published content?
Wait, can you have draft media content? Maybe that's not a thing
You
canuse drafts on media but it's kind of weird to think about tbh
Why not make your collections where you
consumethe media draft instead?
And handle access controls there
I'm not sure I follow, but that's okay - this solution actually solves it for my case
Do you mean like, rewrite the URL in the media propery on a page object for example?
You have posts that are drafts -> use access controls here
You have media that you don't want to thread through payloads access controls -> use the property from above
Yeah, that just exposes all the media - it's not highly discoverable, but if someone could guess the URL, they could get the media. In our case, that's fine.
Right, that's what disablePayloadAccessControl does
Yeah this works - thanks!
My pleasure
Actually, there's one more question - this setting will make it use the bucket URL - is there a way to rewrite that to point to another URL? In our set up, we have a bucket, behind a cloudfront CDN. I'd like it to use the cloudfront URL, not the bucket URL.
You can override it with the
generateFileURLoption
super, thanks
Where do I add disablePayloadAccessControl: true - it's not clear from the docs
Payload build config upload options
Like this?
Ah, no in the adapter config rather
Iirc
It seems to complain no matter where I put that:
Am I using some out of date method to configure this maybe?
cloudStorage({
collections: {
'my-collection-slug': {
adapter: theAdapterToUse,
disablePayloadAccessControl: true
},
},
}),Yeah, I'm not using cloudStorage - I guess I need to figure that out first
Try swapping out your collections.media for { ... } and put it in there
hmm, that works
so that can be a config object, good to know
Star
Discord
online
Get dedicated engineering support directly from the Payload team.