Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async download(item) {
try {
const filename = (item && item.name) ? item.name : this.innerValue[0].name;
const blob = await this.machineDownload({ filename: Path.combine(this.innerDirectory, filename), type: 'blob' });
saveAs(blob, filename);
} catch (e) {
if (!(e instanceof DisconnectedError) && !(e instanceof OperationCancelledError)) {
// should be handled before we get here
console.warn(e);
}
}
},
async edit(item) {
const downloadFile = (blob, name, el) => {
try {
if (hasFileSaverSupported) {
return saveAs(blob, name);
}
// Bad blob support, make a data URI, don't click it
const reader = new FileReader();
reader.onloadend = () => {
el.href = reader.result;
};
reader.readAsDataURL(blob);
} catch (error) {
console.error(error);
}
};
return this.getFile(decryptProgressCallback = console.log, downloadProgressCallback = console.log).then(file => saveAs(file));
}
let results = (sheets ? unwind(e.results, "categories"): e.results).map(item => {
let newItem = {};
for (let column of columns) {
let value = "";
if (typeof column.accessor === "function") {
value = column.accessor(item);
}
else {
value = get(item, column.accessor);
}
newItem[column.Header] = value;
}
return newItem;
}
);
saveAs(new Blob([Papa.unparse(results)]), `treehacks-hacks-${Date.now()}.csv`);
dispatch(setExportedApplications(results));
dispatch(loadingEnd());
}).catch(e => {
console.error(e);
zip.generateAsync({type:"blob"}).then((content) => {
saveAs(content, 'urbit-wallet.zip');
this.setState({ downloaded: true });
});
}
const downloadFile = (blob, fileName) => {
if (browserData.isChrome) {
saveAs(blob, fileName)
} else {
browser.tabs.sendMessage(currentTab, {
action: 'saveFile',
file: {
content: blob,
name: fileName
}
})
}
}
zip.generateAsync({ type: 'blob' }).then(content => {
saveAs(content, 'urbit-wallets.zip');
setTimeout(() => {
saveAs(encoded_urbit_registration, 'urbit-registration.txt');
props.setGlobalState({ didClickDownload: true });
}, 2000);
});
};
getThemeContent(filename).then(data => {
const blob = new Blob([data], { type: 'text/css;charset=utf-8' });
saveAs(blob, filename);
});
}
const download = (theme) => {
const clean = convert(theme);
const fileToSave = new Blob([JSON.stringify(clean)], {
type: 'application/json',
name: 'theme.json',
});
saveAs(fileToSave, 'theme.json');
return Promise.resolve();
};
zip.generateAsync({ type: 'blob' }).then(blob => {
saveAs(blob, defaultZipFilename);
});
}