Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

download function do not work #793

Open
andy-yu-y opened this issue May 16, 2023 · 2 comments
Open

download function do not work #793

andy-yu-y opened this issue May 16, 2023 · 2 comments

Comments

@andy-yu-y
Copy link

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
Copy link

I am also facing the same issue.

@demuanov
Copy link

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");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants