eligrey / FileSaver.js

An HTML5 saveAs() FileSaver implementation
https://eligrey.com/blog/saving-generated-files-on-the-client-side/
Other
21.39k stars 4.38k forks source link

download function do not work #793

Open andy-yu-y opened 1 year ago

andy-yu-y commented 1 year ago

const saveFolder = () => { FileSaver.saveAs( 'serverurl/proj/otbstorage/logs/sched-432cc428-ddae-11ed-bad5-662cc6ee3b0c/mb_output_ids.txt', 'a.txt', ); };

Above is my code, instead of download the file, the browser directly open the file. I google a lot recently, it may caused by fetching file from serverurl not localhost. But i can not find any way to fix this. Can anyone take a look and help about this issue?

amuchand47 commented 1 year ago

I am also facing the same issue.

demuanov commented 11 months ago

Hi am not an expert but you probably provide a link in the wrong way: 1) It should be full URL where the browser automatically sets the correct Content-Type headers saveAs( "https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg", "cat.jpeg" );

2) Or wrap it to blob/file var blob = new Blob(["some text"], { type: "text/plain;charset=utf-8;", }); saveAs(blob, "thing.txt");