eligrey / FileSaver.js

An HTML5 saveAs() FileSaver implementation
https://eligrey.com/blog/saving-generated-files-on-the-client-side/
Other
21.39k stars 4.38k forks source link

Error when attempting to download static file #800

Open randyDarsh opened 9 months ago

randyDarsh commented 9 months ago

I'm thought I solved my issue using FileSaver, and it was working, but now I'm back to getting the same error.

I have two template files, both of which are .xlsx file types. They are static, and are in the public directory of my react application.

I have a function that is called from clicking a Link component.

The method is as follows:

const downloadTemplate = () => {
    try { 
        var isFileSavedSupported = !!newBlob;
   } catch (e) {
        enqueueSnackbar('Unsupported brower. Downloading is not permitted', {variant: 'error'});
        return;
   }
   if(!settings.bulkUpload) {
        FileSaver.saveAs(process.env.PUBLIC_URL + "/scoping-sheet/ScopingSheet.xlsx", "ScopingSheetTemplate.xlsx", {autoBom: true});
    else {
        FileSaver.saveAs(process.env.PUBLIC_URL + "/scoping-sheet/Bulk-scoping-sheet.xlsx", "BulkScopingSheetTemplate.xlsx", {autoBom: true});
    }}

When attempting to download either of the files using Edge (version 117.0.2045.60) and in Chrome (version 117.0.5938.150), on the download tab of each browser, I receive "Couldn't download - Network Issue" and "Failed - Network Error" respectively.

Any ideas would be appreciated.