我有一个Angular 2应用程序连接到Web Api后端.有一个端点返回存储在sql数据库中的图像的byte [].如何在Angular中将其显示为图像?我可以更改Web Api或Angular应用程序.
我的Web Api端点看起来像这样......
[Route("api/profileimage/{userId}")]
public byte[] Get(string userId)
{
var image = _profileImageService.GetProfileImage(userId);
return image;
}
Run Code Online (Sandbox Code Playgroud)
我的Angular HTML看起来像这样......
<img src="http://localhost:2116/api/ProfileImage/{{tile.UserId}}" width="100" height="100"/>
Run Code Online (Sandbox Code Playgroud)
我需要做什么转换,或api应该提供什么?