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
Neto
Neto•2y ago
How big is the file? You can just send the json data to the frontend and save to CSV there
danmrkw
danmrkw•2y ago
thanks for the reply. it's up to 2000 rows so I'll give that a try.
Neto
Neto•2y ago
If the file contents won't update that often You can store in S3 and just send a public link
danmrkw
danmrkw•2y ago
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
Neto
Neto•2y ago
You can check if only sending json is good enough for that case
danmrkw
danmrkw•2y ago
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... 😄
Neto
Neto•2y ago
if works for you
Want results from more Discord servers?
Add your server