How to use the file-saver.saveAs function in file-saver

To help you get started, we’ve selected a few file-saver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nteract / nteract / packages / epics / src / contents.ts View on Github external
export function downloadString(
  fileContents: string,
  filepath: string,
  contentType: string
): void {
  const filename = filepath.split("/").pop();
  const blob = new Blob([fileContents], { type: contentType });
  // NOTE: There is no callback for this, we have to rely on the browser
  //       to do this well, so we assume it worked
  FileSaver.saveAs(blob, filename);
}
github openpowerquality / opq / view / app / imports / ui / pages / eventDetails / eventDetails.js View on Github external
const calibratedSample = sample / constant;

          // return [timestamp, calibratedSample];
          return calibratedSample;
        });

        // eslint-disable-next-line max-len
        const eventPicked = _.pick(boxEvent, 'event_id', 'box_id', 'event_start_timestamp_ms', 'event_end_timestamp_ms', 'waveformCalibrated');
        if (export_type === 'json') {
          const json = JSON.stringify(eventPicked, null, 2);
          const blob = new Blob([json], { type: 'application/json; charset=utf-8' }); // eslint-disable-line no-undef
          Filesaver.saveAs(blob, `event-${eventPicked.event_id}-device-${eventPicked.box_id}`);
        } else if (export_type === 'csv') {
          const csv = Papaparse.unparse([eventPicked]);
          const blob = new Blob([csv], { type: 'text/csv; charset=utf-8' }); // eslint-disable-line no-undef
          Filesaver.saveAs(blob, `event-${eventPicked.event_id}-device-${eventPicked.box_id}`);
        }
      }
    }
    /* eslint-disable camelcase, no-console, no-shadow */
  },
});
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / core / utils / file_export.ts View on Github external
export function saveSaveBlob(payload: any, fname: string) {
  const blob = new Blob([payload], { type: 'text/csv;charset=utf-8;header=present;' });
  saveAs(blob, fname);
}
github polkadot-js / apps / packages / app-accounts / src / modals / Create.tsx View on Github external
export function downloadAccount ({ json, pair }: CreateResult): void {
  const blob = new Blob([JSON.stringify(json)], { type: 'application/json; charset=utf-8' });

  FileSaver.saveAs(blob, `${pair.address}.json`);
  InputAddress.setLastValue('account', pair.address);
}
github opencollective / opencollective-frontend / src / components / expenses / InvoiceDownloadLink.js View on Github external
async download() {
    const invoiceUrl = this.getInvoiceUrl();
    const getParams = { format: 'blob', allowExternal: invoiceServiceURL };

    this.setState({ isLoading: true });
    try {
      const file = await api.get(invoiceUrl, getParams);
      this.setState({ isLoading: false });
      return saveAs(file, this.getFilename());
    } catch (e) {
      this.setState({ error: e.message, isLoading: false });
    }
  }
github choerodon / choerodon-front-agile / agile / src / app / agile / containers / program / Feature / FeatureComponent / ExportIssue / ExportIssue.js View on Github external
.then((data) => {
        const blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
        const fileName = `${AppState.currentMenuType.name}.xlsx`;
        FileSaver.saveAs(blob, fileName);
        Choerodon.prompt('导出成功');        
        onCancel();
      });
  };
github Aam-Digital / ndb-core / src / app / admin / admin / admin.component.ts View on Github external
private startDownload(data: string, type: string, name: string) {
    const blob = new Blob([data], { type: type });
    FileSaver.saveAs(blob, name);
  }
github neo4j / neo4j-browser / src / browser / modules / Frame / FrameTitlebar.jsx View on Github external
const asTxt = frame.result
        .map(result => {
          const safe = `${result}`.trim()

          if (safe.startsWith(':')) {
            return safe
          }

          return safe.endsWith(';') ? safe : `${safe};`
        })
        .join('\n\n')
      const blob = new Blob([asTxt], {
        type: 'text/plain;charset=utf-8'
      })

      saveAs(blob, 'history.txt')
    }
  }
github atlasmap / atlasmap / ui-react / packages / atlasmap-core / src / common / data-mapper-util.ts View on Github external
return new Promise((resolve) => {
      saveAs(fileContent, fName);
      resolve(true);
    });
  }
github choerodon / agile-service-old / react / routes / Issue / ExportIssue / ExportIssue.js View on Github external
.then((data) => {
        const blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
        const fileName = `${AppState.currentMenuType.name}.xlsx`;
        FileSaver.saveAs(blob, fileName);
        Choerodon.prompt('导出成功');
        IssueStore.setExportModalVisible(false);
      }).finally(() => {
        this.setState({

file-saver

An HTML5 saveAs() FileSaver implementation

MIT
Latest version published 3 years ago

Package Health Score

77 / 100
Full package analysis