0

If I write:

res.status(200).download(p, 'he/lo/ldkaf/fd.mp3');

the download will show up as:

fd.mp3

currently the only workaround is turning all the slashes into spaces:

res.status(200).download(p, 'he/lo/ldkaf/fd.mp3'.split('/').join(' '));

But I'd like to keep the slashes. Is there a solution to this problem?

underscore
  • 255
  • 4
  • 9

1 Answers1

0

The second parameter to .download() is a filename only (no path) that should be offered as the default filename in the browser if/when the browser saves the file. Slashes are not allowed because they are not a legal character in a filename (since they are typically path separators) and any path suggested by a server would be ignored by a browser (as a security issue).

jfriend00
  • 683,504
  • 96
  • 985
  • 979
  • I considered this, but (at least on *nix) slashes are supported in filenames. I suppose this is correct and I'll just have to swap them for another character. Thanks. – underscore Jan 09 '18 at 03:53
  • @underscore - Not sure how you think *nix can have a forward slash in a filename: [Is it possible to use “/” in a filename](https://stackoverflow.com/questions/9847288/is-it-possible-to-use-in-a-filename) – jfriend00 Jan 09 '18 at 03:54
  • Then just OS X* My bad. – underscore Jan 09 '18 at 04:35