Monday, 29 May 2017

Express .download method doesn't change the filename

I'm trying to use express to serve a specific file, however, I need to change the name of the file when the user tries to download it, so the user is promted with a different filename than the original one.

So far, I've been trying using express download method, which is supposed to do exactly this if the second parameter is set:

app.get("/file", (req, res) => {
    res.download("originalUglyName", "nice_formated_name");
});

However, the download is promtped with "originalUglyName", regardless of the second parameter. ¿Is there a proper way of doing this?

Currently using Express@4.15.2 and node@6.9.0



via angrykoala

No comments:

Post a Comment