Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

524 B
Raw Blame
export const saveAsFileAndRevokeObjectURL = (url: string, fileName: string) => {
    const a = document.createElement("a");
    a.style.display = "none";
    a.href = url;
    a.download = fileName;
    document.body.appendChild(a);
    a.click();
    URL.revokeObjectURL(url);
    a.remove();
};

export const saveStringAsFile = (s: string, fileName: string) => {
    const file = new Blob([s], { type: "text/plain" });
    const fileURL = URL.createObjectURL(file);
    saveAsFileAndRevokeObjectURL(fileURL, fileName);
};