Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
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 */
},
});
export function saveSaveBlob(payload: any, fname: string) {
const blob = new Blob([payload], { type: 'text/csv;charset=utf-8;header=present;' });
saveAs(blob, fname);
}
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);
}
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 });
}
}
.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();
});
};
private startDownload(data: string, type: string, name: string) {
const blob = new Blob([data], { type: type });
FileSaver.saveAs(blob, name);
}
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')
}
}
return new Promise((resolve) => {
saveAs(fileContent, fName);
resolve(true);
});
}
.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({