0

I'm using the 'window.open()' function but when the file doesn't have an extension (when the filename is only an uuid for example), the file is getting downloaded instead of opening in new tab.

When the file has an extension, there's no problem.

const folder = '/destination_folder/';
var url = folder.concat('', uuid);
window.open(url);

I am using Twig by the way.

Thank you !

DarkBee
  • 16,592
  • 6
  • 46
  • 58
Guitou
  • 1
  • Well, how would the browser/OS know how to open the file if it doesn't have an extension? Are you providing the appropriate MIME type in the Content-Type HTTP header? – Heretic Monkey Oct 22 '20 at 13:28
  • No I'm not, is there a way to provide appropriate MIME type in JavaScript ? – Guitou Oct 22 '20 at 13:51
  • Probably not, since it appears you're pointing to a folder location rather than a data URI. – Heretic Monkey Oct 22 '20 at 13:59
  • Well, yes as you said, it looks like it is not possible to do this in Javascript but in server configuration. Thank you. :) – Guitou Oct 22 '20 at 14:15

0 Answers0