Download
Answered
Spectacled Caiman posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Spectacled CaimanOP
I have an endpoint which downloads the users account information and this can get huge so I don't want to send it over in the request body. How can I download a file on the users PC upon sending an API request. Because in plain nodejs I can just do res.download(filePath);
Answered by Spectacled Caiman
Yeah I decided to zip it and upload it using
uploadthing
and email the user the download link once it's finished26 Replies
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
where is the data stored...
as if it is in your server, you have to send it in response
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Spectacled CaimanOP
It's in a db.
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
but as its in a db (because all the user stored), you could upload it to some storage api (like s3 - but don't use s3 as no permissions for security) and give the user a url to download - but it is simpler to just send it as a response...
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Spectacled CaimanOP
oh that's actually really good.
But the reason that I don't send it over response is that it can easily become 1GB of data
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
idk about other services... but discord sends you an email (can take up to a week after req), and then it sends you an email with a link to download for up to 30 days later
yeah that is a lot... you would def want that as its own zip
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Spectacled CaimanOP
yeah Spotify does the same
yeah alright so I'll connect it to S3 thanks
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
and is this self hosted or something live vercel?
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Spectacled CaimanOP
It's gonna be opensourced but also a web version on vercel
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
im not sure how security s3 is and you don't need the benfits of s3 (like edge caching)
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Spectacled CaimanOP
yea
I may be able to use the blob storage on vercel
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
yeah that is what i was thinking
as you can have "private" data
but how long does it take you to produce said data, like the timeouts on serverless function is only 10sec for base tier(and idk about the max ram usage to make the 1gb file)
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Spectacled CaimanOP
ohhh shi
I guess ill change the approach and have it accessible in some other way.
I mean i'd still have to use the DB/storage but the way that I setup is gonna be different.
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
yeah that makes sense
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Spectacled CaimanOP
alright well thanks for everything
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
@Spectacled Caiman just to check, did you end up finding a solution?
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Spectacled CaimanOP
Yeah I decided to zip it and upload it using
uploadthing
and email the user the download link once it's finishedAnswer
![Avatar](https://cdn.discordapp.com/avatars/657067112434499595/c78dd8e985ede1ad50c31ac682dd91a1.webp?size=256)
risky
Ahh very nice