Created
April 3, 2012 14:21
-
-
Save shauns/2292372 to your computer and use it in GitHub Desktop.
Node base64 decode
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
console.log('Hello, World!'); | |
var fs = require('fs'); | |
var amqp = require('amqp'); | |
var connection = amqp.createConnection({ url: 'amqp://subbydev/base64tests' }); | |
// Wait for connection to become established. | |
connection.on('ready', function () { | |
// Create a queue and bind to all messages. | |
// Use the default 'amq.topic' exchange | |
connection.queue('file_packages', {durable: true, autoDelete: false}, function(q){ | |
// Catch all messages | |
q.bind('base64_payloads', 'payloadmessage'); | |
// Receive messages | |
q.subscribe(function (message) { | |
// Print messages to stdout | |
var base64String = message.data.toString('utf8'); | |
console.log(base64String); | |
var decoded = new Buffer(base64String, 'base64'); | |
fs.writeFile('temp.pdf', decoded, function(err) {}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment