I have a multisite install -- set for using subdomains and mapped domains -- with websites from several clients on it and I would like to create a copy of each and any uploaded media file of my clients subsite to Main website (or a specific subsite which I will call Repository). i.e. client X uploads a photo, it should be copied to my main website (or Repository website).
What would be the best way to go, performance and security wise?
subsites ping the Main or Repository website with a custom endpoint to let it know there's new media and Main/Repository website copies the files using media_handle_upload or media_handle_sideload, for example
Allow subsites upload Main/Repository website using WP REST API media endpoint
Giving some context and use case:
And I am using a cloud service for image optimization, which limits each account and API Key to 1 domain. I want to avoid the hassle of creating and managing an account and an API key for each client of mine and, therefore, I want to use Main website for optimizing all images with one account/API key to optimize the images
I don't want any "ready" code. I am really interested in the ideas and considerations for each way.
There are similiar questions, but they are not exactly the same problem and use case because...
Network Shared Media and plugins like it
Plugins like Network Shared Media don't solve the problem. I don't want clients seeing each other files and the optimization plugin won't see the images in the /sites/site_id/ directory, it will optimize images only in the folder for the main website.edit
I want to do it programatically, not using export/import. As soon as the client uploads something to his/her website, it copies to the Repository site.