I wanted to have the ability to download a csv file stored in s3 from a browser, so I wrote the following code using FileSaver.js.
import { saveAs } from 'file-saver';
const downloadUrl = () => {
saveAs(
'https://-----s3 url--- ',
'filename'
)
}
<button onClick={downloadUrl}>click to download</button>
It works in chrome and firebox, but only in safari on Mac, the file is not downloaded and the page just transitions.
And there is garbled text.
In order to solve this problem
I tried other methods like the following, but they did not work.
<a
href='https://-----s3 url--- '
download
>
click to download
</a>
Is there a better way to figure out this problem?
Thank you.