我有一个SQL服务器数据库,其中包含varbinary
类型的图像。我需要转换varbinary
并将图像返回到网页。帮助将不胜感激。
我发现了这个,它非常有帮助,但我反过来需要它。 节点.js如何从MS SQL服务器数据类型的varbinary转换为图像
像...
var image = new Buffer(rs.recordset[0].Image).toString('base64');
res.type('image/jpeg; charset=utf-8');
res.status(200).end(image);
<ng-template ngbSlide *ngFor="let image of images">
<img class="center-block" src="data:image/JPEG;base64,{{image}}">
</ng-template>
我的服务是这样的...
getImage(query){
return this._http.get(this.API_URL + this.baseUrl + query)
.map(res => res.json());
}
这就是答案。
res.writeHead(200, {'Content-Type': 'image/jpeg'});
//var image = rs;
var image = new Buffer(rs.recordset[0].Image);
res.end(image);