2017-10-13 29 views
0

我从express获得如下的响应。我想,以显示角度2.SQL Server中图像数据类型的值以角度2.0显示图像,快速响应

  • 数据库这个supertendentsSignature图片:SQL服务器
  • Dataytpe:图片
  • ORM:Sequelize
  • 数据类型SuperintendentsSignature列的是Blob
  • 框架:快速
  • 前端:Angular 2.0

我能做些什么?有谁能够帮助我?

{ 
    "status" : 'Active', 
    "FName" : 'test', 
    "SuperintendentsSignature": { 
     "type": "Buffer", 
     "data": [ 
      91, 
      111, 
      98, 
      106, 
      101, 
      99, 
      116, 
      32, 
      79, 
      98, 
      106, 
      101, 
      99, 
      116, 
      93 
      ] 
    } 
} 
+1

'ntext','text'和'image'数据类型将在SQL Server的未来版本中删除。避免在新的开发工作中使用这些数据类型,并计划修改当前正在使用它们的应用程序。改为使用'nvarchar(max)','varchar(max)'和'varbinary(max)'。 [见详细信息](http://msdn.microsoft.com/en-us/library/ms187993.aspx) –

+0

是的,但是,这个系统正在运行。所以,我不能改变这一点。任何想法如何显示图像? –

回答

0

Datauri npm用于从缓冲区对象中获取数据uri以显示图像。

https://www.npmjs.com/package/datauri

const Datauri = require('datauri'), 
const datauri = new Datauri(); 

//... 
const buffer = data.SuperintendentsSignature; // Buffer data 
//... 

datauri.format('.png', buffer); 

console.log(datauri.content); //=> "data:image/png;base64,eGtjZA==" 
console.log(datauri.mimetype); //=> "image/png" 
console.log(datauri.base64); //=> "eGtjZA==" 
console.log(datauri.getCSS({ 
    class: "myClass", 
    width: true, 
    height: true 
})); //=> adds image width and height and custom class name