我正在设计我的数据库以保存用户个人资料的记录。
这些用户个人资料有标准:标题,名称,传记,每个都有一张我需要保存在表格中的图片
标题 名称 传 图像
我需要为Web开发人员生成XML输出以在网站中使用,是否可以在XML中发送此图像,或者他是否需要在他可以访问的位置使用这些图片?
希望这是有道理的。
谢谢,劳伦
答案 0 :(得分:2)
不知道这是否是您所需要的,但SQL-Server的FOR XML PATH()
会将二进制值隐式编码为Base64
:
SELECT 'The Title' AS [@Title]
,'The Name' AS [@Name]
,0x1234567890ABCDEF AS [Base64EncodedBinary]
FOR XML PATH('Test');
结果
<Test Title="The Title" Name="The Name">
<Base64EncodedBinary>EjRWeJCrze8=</Base64EncodedBinary>
</Test>
此Base64-string
可以用作<img>
- 直接来源...
这需要SQL-Server 2008+。早期版本2005隐式地将二进制文件编码为HEX字符串...
将其复制到一个文件&#34; Surprise.html&#34;然后双击它:
<html><body>
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABgREhUSDxgVFBUbGhgdJDwnJCEhJEo1OCw8WE1cW1ZNVVNhbYt2YWeDaFNVeaV6g4+UnJ2cXnSrt6mXtYuZnJX/2wBDARobGyQgJEcnJ0eVZFVklZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZX/wAARCADIAa8DASIAAhEBAxEB/8QAGgAAAwEBAQEAAAAAAAAAAAAAAAECAwQFBv/EADAQAAICAQMEAQMEAgICAwAAAAABAhEDEiExBEFRYSITcZEFMoGxFKEjQlLRFcHw/8QAGAEBAQEBAQAAAAAAAAAAAAAAAAECAwT/xAAgEQEBAQEBAAIDAQEBAAAAAAAAARECIQMxEkFRIhNh/9oADAMBAAIRAxEAPwDo1WDd/YlyQOSOLop77jUnEm02DkgrXVe4vZnY9YRVjTIcr5QtVtEVpfsHKjPVbCwK1C1WyHIlsLF6vBP1Ke5DlvsyXKkRUdVO8Zwwl4OrL8onJF06M9OnDpxukWpV2M8bS3Kb8eD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