将base64编码转化成图片,可以使用sofer
- sofer下载:
npm i sofer
- sofer源代码地址:
https://github.com/shataniya/sofer
- 使用 sofer搭建服务器
// server.js
const sofer = require("sofer")
const server = new sofer()
server.use(sofer.cors("null"))
server.post("/index",ctx=>{
// 如果不设置文件的存放路径,那么会默认存放在 media文件夹里
// 设置文件名为 demo
ctx.media("demo")
ctx.body = "server have received the base64 code