我正在使用与Dynamics 365进行通信的使用nodejs和ionic的应用程序。
我的问题是我不了解图像的返回。
根据the contact EntityType documentation
entityimage Edm。二进制显示记录的默认图像
以下是返回图像的CRM的信息:
/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCACQAJADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD0bx0rP4j8KqilmM1wAAP+mJqjfM8VlcsMq6RsR6ggVteKT5fizwfKTgC9mT84H/wp3ibSZJbW8uLb5t8LlhkcfL2rWnO2jMakLu6OF07T7i70+C4bU7pVdFJ/ftnOQPX3/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yD1GfQipb7UBcaVOttFHiEK4AY4wpyMccjjtWl9bsxjJctjrdG1WCTSLczXIMgUqS55OCRk+/FbHw9dJvE3iqaNg0Ze1QEdyIyT/ADrzi0Ey2/79UWRnZmCHIGWJ/rXf/CJcw+IJfW/C/lEn+NEpNxHS+N2K/wAW/wDkKeGQRkbrk/8Aji1xuxCMlF/KvS/iL4Y1TX/7KuNKELzWUkhaOZyoZXXHXB54Fcb/AMIR4xIz9gsPobo//E1KaHVhJyujENvCesSH/gNVPs0225TyIAs21SMAjCvuHbr26966NvCHi+Pro0L/APXO6H9RUT+GvFkfXw7K3+5cIf5kU7pkKNSOxhJbRwyLItlGHXoyjpVj7Q38ULitIeH/ABWwyvhq5/4FPGP601vD/i1OT4YuCP8AZuIz/Wi6JcJvdGW/kSNueJg3TOMZHp9KhE0YuG2wSf61SCvAwEYZx/wI/kK0msddQ7ZPDmpBv9lFb+RqI2+qyKyr4f1YkjHNvj+tDsylGa6HRXcO39nG3HYxwSH8bhWP865b+zbT/niB9K9El0HVbv4HRaMlm/8AaP2OJRASAcq6nHPGcCuUj8L+Lpvu+H/L/wCutyo/lmkrdTWopO3KYv8AZtqRwrj2DkUf2ZB2aYfSVh/Wt7/hEvFwJB0SIkdxdDB/Sq0uh+J4H2yeHLknGf3csbf1FP3TK1UyDpcRUqZrjBGCDMxq5GixxrGgwqgKB7Cle21mIEy+HtUUD+7EG/kaiL3oGTourAf9ebUKy2JlGo9yDUbiOAQ75FVvMBAJ/X9aqqyfY4ow6gtaouM8n5lFW5pcgfatM1BFHQy2bgD9Kp/aNGjmMzna+QcyRsMEfUcUmrgk0tUa/au/+EKAaBq0nd9Vmz+CoP6V5l/bWm4z9tix9a9J+Dlws/h7VdhJj/tORkbHDBlQ8fjmnI0oJp6n/9k=
此格式是什么?如何转换它以便显示图像?
编辑1
我已经尝试过
var img = document.createElement('img');
img.src = 'data:image/jpeg;base64,' + btoa('your-binary-data');
document.body.appendChild(img);
但不起作用
答案 0 :(得分:1)
这里有一个使用实体图像here的示例。它是C#,但适用相同的基本原理。
使用entityimage属性检索记录,并保存 调整大小的文件。
//Retrieve and download the binary images
string binaryImageQuery = String.Format(@"<fetch mapping='logical'>
<entity name='{0}'>
<attribute name='sample_name' />
<attribute name='entityimage' />
</entity>
</fetch>",_customEntityName.ToLower());
EntityCollection binaryImageResults = _serviceProxy.RetrieveMultiple(new FetchExpression(binaryImageQuery));
Console.WriteLine("Records retrieved and image files saved to: {0}", Directory.GetCurrentDirectory());
foreach (Entity record in binaryImageResults.Entities)
{
String recordName = record["sample_name"] as String;
String downloadedFileName = String.Format("Downloaded_{0}", recordName);
byte[] imageBytes = record["entityimage"] as byte[];
var fs = new BinaryWriter(new FileStream(downloadedFileName, FileMode.Append, FileAccess.Write));
fs.Write(imageBytes);
fs.Close();
Console.WriteLine(downloadedFileName);
}
答案 1 :(得分:0)
我要做的就是
let img = "data:image/png;base64,"+ "binary-data";