0
<a href={getDocLink(item.data)} download={item.name}> // item: { data: <base64URL>, name: 'Mortality' }
  Download
</a>
const getDocLink = (url) => {
  const str = url.substring(url.indexOf(";") + 1);
  return `data:text/csv;base64,${str}`;
};

When i run this code in mac, i am able to download file like Mortality.csv once i click on Download, But when i run the same in windows, i am able to download a file but, its not saving as .csv, It is saving without .csv format like Mortality

iamPavan
  • 255
  • 4
  • 15

1 Answers1

1

add .csv to download

<a href={getDocLink(item.data)} download={item.name+ '.csv'}> // item: { data: <base64URL>, name: 'Mortality' }
  Download
</a>
Hoang Le
  • 78
  • 3