portfolio-redux-app icon indicating copy to clipboard operation
portfolio-redux-app copied to clipboard

Dowload file from own server

Open danielstorch opened this issue 9 years ago • 2 comments

Hello! Is there a way i can let the user download a file on my own server? You are using promise to get data from github, but it doesn't work when downloading from localhost.

I think because of the universal get method, i always get page 404.

danielstorch avatar Dec 10 '15 16:12 danielstorch

Hi Daniel,

Express can do that for you. You just need to add a route before the /* get route. i.e.


app.get('/path/to/file', function (req, res) {
}

app.get('/*', function (req, res) {
}

to send the file via express check out the following : http://stackoverflow.com/questions/11569181/serve-static-files-on-a-dynamic-route-using-express.

You could also just run the app in production mode and add the file to the dist folder and link directly too it. The path would then be /static/file.zip

caljrimmer avatar Dec 11 '15 12:12 caljrimmer

Perfect thanks! Another question, when trying to download the file with express res.download, the browser doesn't show it (doesn't prompt the download). When i use localshost:3002/api/download directly in my browser i can download it. I think it is a security reason, but i can't find a proper way of doing this.

Also im trying to upload the app to heroku, but it tells me that it can't find favicon.ico. Can't figure out how fix that.

danielstorch avatar Dec 11 '15 16:12 danielstorch