React + Django: best practices for generating + downloading file?
I am working on an app which uses React and Django. I need a functionality whereby a user on the app can click a button and download a csv file on their machine. Importantly, the file is not already available anywhere, it needs to be generated on the fly when the user requests it (by clicking on the download button).
I am thinking of implementing this flow:
- when the user clicks on the button, an API call is made which tells the backend to generate the csv file and store it in an s3 bucket
- the backend then sends a response to the frontend which contains the URL that the frontend can access to download the file from the s3 bucket
- the file gets downloaded
Would this be a good approach? If not, what is the best practice for doing this?