How to Expose Custom S3 File Upload Hook as External API?

Hi everyone,

I’ve overridden the file upload hook in Frappe to upload files directly to S3, and it’s working perfectly within the Frappe UI.

Now, I want to expose this functionality as an external API so that third-party apps (like a mobile or frontend app) can also upload files directly to S3 using the same logic.

What’s the best way to do this in Frappe?

  • Should I create a custom whitelisted method that accepts the file and reuses the same logic as the hook?
  • Is there a way to expose the same hook logic via a REST endpoint?
  • How do I handle the file stream or base64 from an external client in this context?

Any guidance or example implementations would be appreciated!

Thanks in advance!