So I'm building a RESTful API for a "Development Platform" project using Django and want to setup a upload/download feature where the users of the platform can upload various files (Excel files, css files, pdf files, C# scripts, unity packages, blender files etc) and other users can then download these files through an endpoint. I have the upload file endpoint configured and properly working.
At the download file endpoint, I want to receive the filename that the user wants to download and also verify the user's credentials and permissions for downloading that file and do some other model queries and checks too and finally find that file in my /media/ folder and serve it to the user's browser for auto downloading or a download pop-up on the browser. (This download file endpoint would get hit when user presses "Download File" button on the frontend).
How can I achieve this in django? Could someone provide a sample piece of code to "send" that file, once fetched from the media folder, as a response to the user's browser for downloading?