Download
Answered
Spectacled Caiman posted this in #help-forum
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
where is the data stored...
as if it is in your server, you have to send it in response
Spectacled CaimanOP
It's in a db.
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...
Spectacled CaimanOP
oh that's actually really good.
@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...
Spectacled CaimanOP
But the reason that I don't send it over response is that it can easily become 1GB of data
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
@Spectacled Caiman But the reason that I don't send it over response is that it can easily become 1GB of data
yeah that is a lot... you would def want that as its own zip
Spectacled CaimanOP
yeah Spotify does the same
@risky yeah that is a lot... you would def want that as its own zip
Spectacled CaimanOP
yeah alright so I'll connect it to S3 thanks
and is this self hosted or something live vercel?
Spectacled CaimanOP
It's gonna be opensourced but also a web version on vercel
im not sure how security s3 is and you don't need the benfits of s3 (like edge caching)
Spectacled CaimanOP
yea
I may be able to use the blob storage on vercel
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)
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.
yeah that makes sense
Spectacled CaimanOP
alright well thanks for everything
@Spectacled Caiman just to check, did you end up finding a solution?
@risky <@1029913381643227157> just to check, did you end up finding a solution?
Spectacled CaimanOP
Yeah I decided to zip it and upload it using
uploadthing
and email the user the download link once it's finishedAnswer
Ahh very nice