Skip to content

Instantly share code, notes, and snippets.

@barooney
Last active April 13, 2018 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barooney/bad2324372562f318e336a238c79c1f4 to your computer and use it in GitHub Desktop.
Save barooney/bad2324372562f318e336a238c79c1f4 to your computer and use it in GitHub Desktop.
Download a binary file with axios and store it from within a CEP panel using cep.fs
function downloadFile(url, filename) {
axios.get(url, { responseType: 'arraybuffer' }).then(res => {
let data = btoa(new Uint8Array(res.data).reduce((data, byte) => data + String.fromCharCode(byte), ''))
cep.fs.writeFile(filename, data, this.cep.encoding.Base64)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment