How can I add an API to download files under a directory?
How can I add an API to download files under a directory?
The frontend send a GET request like "localhost:3001/uploads/test.mp4"
How can I set the
main.wasp
to support the download?3 Replies
Hmmm, what do you exactly want to do, can you explain it with richer detail?
What should the experience be from the user side? Who is providing the files, and where are they stored?
Typically, you don't want to save files uploaded by the user on the server, because servers on most cloud providers are come and go -> they get restarted, reset, you can't count on data on disk being permanent. Instead, files are usually stored on services like S3, Azure blob and similar. Unless your cloud provider explicitly offers you permanent disk storage that you can attach to your server, some do that I believe.
I am happy to give some ideas on how to go about this, but will wait for more details so I don' tprovide wrong info!
Sorry the uploads in url misleading. I want to know how to set up a static file download api for client to download the temp files. Like express.static
Sorry for the slow answer here, got a bit overwhelmed with release of Wasp 0.12 so I accidentaly overlooked this convo! So if you wanted to use
express.static
, you could actually to that, via serverSetup
function: https://wasp-lang.dev/docs/project/server-config#setup-function . You get access to app
here, so you can import express if you wish, and then do something like app.use(express.static('public'))
as described here https://expressjs.com/en/starter/static-files.html .
I am curious about your use case, what exactly do you need this for, what kind of feature?