您好,我接下来有图像类型缓冲区,该数据是一张图像,如何将缓冲区数据转换为图像
当我向 api 发出请求时,它会显示以下数据
任何建议
后端是用node js续集MYSQL制作的.
以及 React js 中的前端
我有下一个例子
https://codesandbox.io/s/happy-christian-z4m1x?file=/src/LoadingData.js
With this he retrieved the data from the MySQL database
这样我就注册了
这样图像就被存储了
首先,您需要转换您的Buffer
to base64
string
const base64String = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer)));
其次,您需要将字符串用作src
属性为img
tag
<img src={`data:image/png;base64,${base64String}`} alt=""/>
我假设你正在使用react
,所以我建议保存base64String
在组件中state
并使用它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)