Hi there,
I am retrieving binary data from a postgres database and display it in the
browser as data-value in an image tag like this:
function(req,res,params)
{
var aPrefkey = params;
var querystring = 'SELECT * FROM qmcustomerdata WHERE prefkey=\'' +
aPrefkey.prefkey + '\'';
dbop.query('','',querystring,function(err,aResult){
var firstItem = aResult[0];
if (typeof firstItem['dataval']!='undefined' && firstItem['dataval']!=null
&& firstItem['dataval'].length>0){
var xb = new Buffer(firstItem['dataval']).toString('base64');
var tt = firstItem['textval'];
var holdt = tt.split('/');
var ft = holdt[1];
var aName = 'asdasdasd' + '.' + ft;
res.writeHead(200);
res.write('<img ' + firstItem['generic_params'] + ' src="' + 'data:' + tt +
';base64,' + xb + '" />','binary');
res.end();
} else {
res.writeHead(200);
res.write(firstItem['textval']);
res.end();
}
});
}
The data does get displayed, and the resulting image tag looks correct with
all the stuff I need, but the browser displays it like that, as a tag with
the characters inside and not as an image, it's just an image tag with base
64data in the browser window then.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.