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

Feature Request: support save file to local disk file #5

Open
ruoyewu opened this issue Dec 22, 2021 · 0 comments
Open

Feature Request: support save file to local disk file #5

ruoyewu opened this issue Dec 22, 2021 · 0 comments

Comments

@ruoyewu
Copy link

ruoyewu commented Dec 22, 2021

I tried to use the code below to save something to local disk file,

    const saveFile = async (name: string, content: string) => {
        printToConsole('start to save file');
        const blob = new Blob([content], { type: 'text/plain' });
        printToConsole(await blob.text());
        const a = document.createElement('a');
        printToConsole(a);
        a.href = URL.createObjectURL(blob);
        a.download = name + '.md';
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
    }

but it dost work.
Is this not supported or there are problems with the code?

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

1 participant