Is it possible to conditionally apply S3/R2 upload prefixes per API route in Payload CMS?
23:17 17 Dec 2025

I’m working with Payload CMS + @payloadcms/storage-s3 + Cloudflare R2.

Requirement:

  • Default media collection uploads should go to the bucket root.

  • Only profile images uploaded via a custom API route should go to user-profile-image/.

  • Profile images must still create a MongoDB document.

I noticed that:

  • prefix applies to the entire collection.

  • Filenames containing / are sanitized.

Is there a supported way to conditionally control the upload path per request?

cloudflare payload-cms cloudflare-r2