Last active
April 13, 2018 04:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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