提交 ba30e812 authored 作者: zyx's avatar zyx

update

上级 7123bee3
...@@ -3,6 +3,7 @@ const path = require('path') ...@@ -3,6 +3,7 @@ const path = require('path')
const com = require('@god/node-com') const com = require('@god/node-com')
const Proxy = com.Proxy const Proxy = com.Proxy
const md5 = com.Tool.md5
const use = (req, res) => { const use = (req, res) => {
Proxy.reqHttps({ Proxy.reqHttps({
...@@ -21,11 +22,12 @@ const use = (req, res) => { ...@@ -21,11 +22,12 @@ const use = (req, res) => {
}, function (str, obj) { }, function (str, obj) {
console.error('获取cookie - 123456789', req.headers.cookie) console.error('获取cookie - 123456789', req.headers.cookie)
if (/image/gi.test(obj.resHeader['content-type'])) { if (/image/gi.test(obj.resHeader['content-type'])) {
// 这种方式不够高级,还要先生成一个图片文件,能不能直接返回一个文档流
res.header('Content-Type', obj.resHeader['content-type']) res.header('Content-Type', obj.resHeader['content-type'])
str = str.replace(/^data:image\/\w+;base64,/, "") str = str.replace(/^data:image\/\w+;base64,/, "")
let bf = new Buffer(str, 'base64') let bf = new Buffer(str, 'base64')
fs.writeFileSync('upload_tmp/image.png', bf) fs.writeFileSync('upload_tmp/image.' + md5(bf) + '.png', bf)
fs.createReadStream('upload_tmp/image.png').pipe(res) fs.createReadStream('upload_tmp/image.' + md5(bf) + '.png').pipe(res)
// 直接返回 base64字符串 // 直接返回 base64字符串
// res.header('Content-Type', 'text/plain') // res.header('Content-Type', 'text/plain')
// res.status(200).send(str) // res.status(200).send(str)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论