type Params = {
    res: Response;
    file_name: string;
};

export default async function downloadFromFetchRes({ res, file_name }: Params) {
    const blob = await res.blob();
    const downloadableUrl = URL.createObjectURL(blob);

    const link = document.createElement("a");
    link.href = downloadableUrl;
    link.download = file_name;
    link.style.display = "none";

    document.body.appendChild(link);
    link.click();

    URL.revokeObjectURL(downloadableUrl);
    document.body.removeChild(link);
}
