const downloadFile = ({ name, content }) => { const file = new Blob([content], { type: 'text/plain;charset=utf-8' }) return new Promise(resolve => { saveAs(file, name) resolve(true) }) }
saveAs() { let filename = 'MyProject.fuxap'; let date = new Date(); let content = JSON.stringify(this.convertToSave(this.getProject())); let blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); FileSaver.saveAs(blob, filename); }
const downloadZip = ({ name = 'my-project', files }) => { const zip = new JSZip() const folder = zip.folder(name) files.forEach(file => zipFile(folder, file)) return zip.generateAsync({ type: 'blob' }).then(blob => saveAs(blob, name)) }
downloadFavorites () { let data = fs.readFileSync(`${app.getPath('userData')}/bookmarks.json`, 'utf8') let fileToSave = new Blob([data], { type: 'application/json', name: 'myBookmarks.shtd' }) saveAs(fileToSave, 'myBookmarks.shtd') }
const ExportCSV = ({csvData, fileName}) => { const fileType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'; const fileExtension = '.xlsx'; const exportToCSV = (csvData, fileName) => { const ws = XLSX.utils.json_to_sheet(csvData); const wb = { Sheets: { 'data': ws }, SheetNames: ['data'] }; const excelBuffer = XLSX.write(wb, { bookType: 'xlsx', type: 'array' }); const data = new Blob([excelBuffer], {type: fileType}); FileSaver.saveAs(data, fileName + fileExtension); } return ( <Button variant="warning" onClick={(e) => exportToCSV(csvData,fileName)}>Export</Button> ) }
printControl.on(['print', 'error'], function(e) { // Print success if (e.image) { if (e.pdf) { // Export pdf using the print info var pdf = new jsPDF({ orientation: e.print.orientation, unit: e.print.unit, format: e.print.format }); pdf.addImage(e.image, 'JPEG', e.print.position[0], e.print.position[0], e.print.imageWidth, e.print.imageHeight); pdf.save(); } else { e.canvas.toBlob(function(blob) { saveAs(blob, 'map.'+e.imageType.replace('image/','')); }, e.imageType); //$('#image img').attr('src', e.image); } } else { console.warn('No canvas to export'); } });
/** * Export view in a file json format MyView.fuxav * @param view */ onExportView(view: View) { let filename = 'MyView.fuxav'; let date = new Date(); let content = JSON.stringify(view); let blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); FileSaver.saveAs(blob, filename); }