Created
March 16, 2014 21:46
-
-
Save cethap/9590364 to your computer and use it in GitHub Desktop.
ShortJsGist
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
var fs = require('fs'); | |
var string = a.body.id; | |
var regex = /^data:.+\/(.+);base64,(.*)$/; | |
var matches = string.match(regex); | |
var ext = matches[1]; | |
var data = matches[2]; | |
var buffer = new Buffer(data, 'base64'); | |
fs.writeFileSync('file.'+ext, buffer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment