create csv on the backend and server for download
I have a table called pollResults. It contains data that my users want to download into a csv file. What is the best way to generate that file on the backend (using t3 stack) and then serve it as a download on the client? ideally without getting anything like S3 involved.
7 Replies
How big is the file?
You can just send the json data to the frontend and save to CSV there
thanks for the reply. it's up to 2000 rows so I'll give that a try.
If the file contents won't update that often
You can store in S3 and just send a public link
the problem is this is sensitive data. so the download link should only be accessible to that user.
and it should destroy in s3 once it is downloaded
and yeah it updates regularly so I'd have to put it into s3 on click
You can check if only sending json is good enough for that case
I am considering offering the option to use the microsoft 365 API to write directly into that users OneDrive
or reading that api doc maybe Google Drive... 😄
if works for you