Created
July 10, 2010 14:28
-
-
Save shimondoodkin/470742 to your computer and use it in GitHub Desktop.
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 http = require('http'); | |
var Buffer = require('buffer').Buffer; | |
var gif; | |
fs.readFile(__filename, function (err, data) | |
{ | |
if (err) throw err; | |
gif = new Buffer(data, 'utf8'); | |
}); | |
http.createServer(function (req, res) | |
{ | |
res.writeHead(200, {'Content-Type' : 'image/gif'}); | |
req.setEncoding('binary'); | |
res.write(gif); | |
res.end(); | |
// Do db magic after the request is sent. | |
}).listen(91); | |
---- | |
simple script same error | |
/var/www/nodejs-mongodb-app/files_page.js:8 | |
gif = new Buffer(data, 'utf8'); | |
^ | |
TypeError: Bad argument | |
at /var/www/nodejs-mongodb-app/files_page.js:8:9 | |
at fs:83:13 | |
at node.js:255:9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment