Upload media with owner check

System Information
  • Strapi Version: 4.5.2
  • Operating System: mac
  • Database: PostgreSQL
  • Node Version:
  • NPM Version:
  • Yarn Version:

Hello there,
I create a new collection type (project) and it has field media. I test upload media by authenticated user and attach media to target project - all works fine.

One thing that I can’t figure out is how to prevent delete media uploaded by another user?

Google says: wow it’s pretty simple “just” create policy/middleware/plugin extension or smth else, but HOW?) Is there any step by step manual? I Tried to create extensions/upload/strapi-server.js with just console log to test when code fired - console empty(

module.exports = (plugin) => {
   

console.log('1111')
  
    return plugin;
  };

So for politices you can have a read here

Which is a policy, what you are doing is a plugin which would override everything of the existing upload one.
Great if you want to customize the whole plugin itself.

But with a policy you execute specific logic like checking user logic BEFORE it goes to the controller etc.