【问题标题】:Node : how to convert from varbinary to image of SQL Server datatype节点:如何从 varbinary 转换为 SQL Server 数据类型的图像
【发布时间】:2018-01-10 10:28:55
【问题描述】:

我有一个带有varbinary 类型图像的 SQL Server 数据库。我需要转换 varbinary 并将图像返回到网页。帮助将不胜感激。

我发现了这个,它很有帮助,但我需要反过来。 Node.js How to convert to image from varbinary of MS Sql server datatype

类似...

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());
    
   }

【问题讨论】:

标签: node.js angular express node-mssql


【解决方案1】:

这就是答案。

res.writeHead(200, {'Content-Type': 'image/jpeg'});
//var image = rs;
var image  = new Buffer(rs.recordset[0].Image);
res.end(image);

【讨论】:

    猜你喜欢
    • 2017-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-24
    相关资源
    最近更新 更多